nikita-volkov/typeclasses/1.3.0

NOTE: the latest version is 1.8.0

Typeclasses.Extensions.List

Extensions to the list API, which utilise typeclasses.

fold : Monoid a -> List a -> a

O(n). Combine the elements of list using a Monoid instance.

foldMap : Monoid b -> (a -> b) -> List a -> b

O(n). Map each element of the list to a type which has an instance of Monoid, and combine the results.

sort : Comparison a -> List a -> List a

Sort the elements using a Comparison instance.

sortBy : Comparison b -> (a -> b) -> List a -> List a

Sort the elements by mapping to a type which has an instance of Comparison.

member : Equality a -> a -> List a -> Bool

O(n). Check whether a value is a member of a list based on the value's Equality instance.

dedupe : Equality a -> List a -> List a

O(n^2). Deduplicate a list using an instance of Equality.