on master help sign in
switch to Elm-style definition for NE.sortBy
4764f95Evan Czaplicki
compiler/src/Data/NonEmptyList.hs+6−2
@@ -52,8 +52,12 @@ instance Foldable List where
52-- SORT BY
52-- SORT BY
53
53
54
54
55−sortBy :: (a -> a -> Ordering) -> List a -> List a
55+sortBy :: (Ord b) => (a -> b) -> List a -> List a
56−sortBy comparison (List x xs) =
56+sortBy toRank (List x xs) =
57+ let
58+ comparison a b =
59+ compare (toRank a) (toRank b)
60+ in
57 case List.sortBy comparison xs of
61 case List.sortBy comparison xs of
58 [] ->
62 [] ->
59 List x []
63 List x []