protolude-0.3.4: A small prelude.
Safe HaskellSafe
LanguageHaskell2010

Protolude.List

Synopsis

Documentation

head :: Foldable f => f a -> Maybe a Source #

ordNub :: Ord a => [a] -> [a] Source #

sortOn :: Ord o => (a -> o) -> [a] -> [a] Source #

list :: [b] -> (a -> b) -> [a] -> [b] Source #

product :: (Foldable f, Num a) => f a -> a Source #

sum :: (Foldable f, Num a) => f a -> a Source #

groupBy :: (a -> a -> Bool) -> [a] -> [[a]] #

The groupBy function is the non-overloaded version of group.

When a supplied relation is not transitive, it is important to remember that equality is checked against the first element in the group, not against the nearest neighbour:

>>> groupBy (\a b -> b - a < 5) [0..19]
[[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14],[15,16,17,18,19]]

It's often preferable to use Data.List.NonEmpty.groupBy, which provides type-level guarantees of non-emptiness of inner lists.