on master help sign in
switch to Elm-style definition for NE.sortBy
commit4764f957f54f27e1b9bd9ee6ae7d4e23fbf1826b authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 12 Jun 2019, 16:51 (7 years ago) parenteaa4b1f
1 file changed+6−2
compiler/src/Data/NonEmptyList.hs+6−2
compiler/src/Data/NonEmptyList.hs+6−2
@@ -52,8 +52,12 @@ instance Foldable List where
5252-- SORT BY
5353
5454
55−sortBy :: (a -> a -> Ordering) -> List a -> List a
56−sortBy comparison (List x xs) =
55+sortBy :: (Ord b) => (a -> b) -> List a -> List a
56+sortBy toRank (List x xs) =
57+ let
58+ comparison a b =
59+ compare (toRank a) (toRank b)
60+ in
5761 case List.sortBy comparison xs of
5862 [] ->
5963 List x []