Copyright | (c) Chris Penner 2018 |
---|---|
License | BSD-3-Clause |
Stability | stable |
Safe Haskell | Safe |
Language | Haskell2010 |
Flux is a monoid which detects the number of times a value changes across a sequence
getFlux $ foldMap flux ["a", "b", "b", "a"] 2 getFlux $ foldMap flux ["a", "b", "b", "a", "c", "c", "c"] 3
Documentation
Flux
is a monoid which counts the number of times an element changes
(according to its Eq instance)
This is useful for gaining associativity (and its associated performance improvements)
for tasks where you'd otherwise use group
or groupBy
It also allows usage of change-detection semantics in situations where a Monoid is required; e.g. in a FingerTree