Copyright | (c) 2018-2019 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Polymorphic grouping functions.
Synopsis
- groupBy :: forall f t a. (Foldable f, DynamicMap t, Val t ~ NonEmpty a, Monoid t) => (a -> Key t) -> f a -> t
- groupOneBy :: forall f t a. (Foldable f, DynamicMap t, Val t ~ a, Monoid t) => (a -> Key t) -> f a -> t
Documentation
groupBy :: forall f t a. (Foldable f, DynamicMap t, Val t ~ NonEmpty a, Monoid t) => (a -> Key t) -> f a -> t Source #
Groups elements using results of the given function as keys.
>>>
groupBy even [1..6] :: HashMap Bool (NonEmpty Int)
fromList [(False,5 :| [3,1]),(True,6 :| [4,2])]
groupOneBy :: forall f t a. (Foldable f, DynamicMap t, Val t ~ a, Monoid t) => (a -> Key t) -> f a -> t Source #
Similar to groupBy
but keeps only one element as value.
>>>
groupOneBy even [1 .. 6] :: HashMap Bool Int
fromList [(False,1),(True,2)]