nikita-volkov / typeclasses / Typeclasses.Extensions.List

Extensions to the list API, which utilise typeclasses.

fold : Typeclasses.Classes.Monoid.Monoid a -> List a -> a

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

foldMap : Typeclasses.Classes.Monoid.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 : Typeclasses.Classes.Comparison.Comparison a -> List a -> List a

Sort the elements using a Comparison instance.

sortBy : Typeclasses.Classes.Comparison.Comparison b -> (a -> b) -> List a -> List a

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

member : Typeclasses.Classes.Equality.Equality a -> a -> List a -> Basics.Bool

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

dedupe : Typeclasses.Classes.Equality.Equality a -> List a -> List a

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

remove : Typeclasses.Classes.Equality.Equality a -> a -> List a -> List a

O(n). Remove the first occurrence of equaling element.