Copyright | (c) Francesco Gazzetta 2017 |
---|---|

License | BSD3 (see the file LICENSE) |

Maintainer | francygazz@gmail.org |

Stability | stable |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell2010 |

Accumulators, primarily useful for Polyvariadic

- class Accumulator acc x where
- singleton :: (Accumulator acc x, Monoid acc) => x -> acc
- accumulateMany :: (Foldable f, Accumulator acc x) => f x -> acc -> acc
- newtype AccumulatorSemigroup a = AccumulatorSemigroup {}

# Documentation

class Accumulator acc x where Source #

An 'Accumulator c i' supports accumulation of elements of type i in it.
This is different from `Semigroup`

or `Monoid`

, where `<>`

acts between
two values with the same type.

:: x | |

-> acc | |

-> acc | Accumulate a value |

Accumulator [a] a Source # | |

Ord a => Accumulator (Set a) a Source # | |

Semigroup m => Accumulator (AccumulatorSemigroup m) (AccumulatorSemigroup m) Source # | |

singleton :: (Accumulator acc x, Monoid acc) => x -> acc Source #

Accumulate a single value in a `Monoid`

accumulateMany :: (Foldable f, Accumulator acc x) => f x -> acc -> acc Source #

Strictly accumulate multiple values from a `Foldable`

, from left to right

newtype AccumulatorSemigroup a Source #

Lift a `Semigroup`

into an Accumulator. This is a newtype because (<>) isn't always the ideal way of accumulating

Semigroup m => Semigroup (AccumulatorSemigroup m) Source # | |

Semigroup m => Accumulator (AccumulatorSemigroup m) (AccumulatorSemigroup m) Source # | |