reducers-3.12.1: Semigroups, specialized containers and a general map/reduce framework

Copyright | (c) Edward Kmett 2009
License | BSD-style
Maintainer | ekmett@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.Semigroup.Generator

Contents

- Generators
- Combinators

Description

A `Generator1` `c` is a possibly-specialized container, which contains values of type `Elem` `c`, and which knows how to efficiently apply a `Reducer` to extract an answer.

`Generator1` is to `Generator` as `Foldable1` is to `Foldable`.

Synopsis

- class Generator c => Generator1 c where
- reduce1 :: (Generator1 c, Reducer (Elem c) m) => c -> m
- mapReduceWith1 :: (Generator1 c, Reducer e m) => (m -> n) -> (Elem c -> e) -> c -> n
- reduceWith1 :: (Generator1 c, Reducer (Elem c) m) => (m -> n) -> c -> n

# Generators

class Generator c => Generator1 c where #

minimal definition `mapReduce1` or `mapTo1`

Minimal complete definition

mapReduce1

Methods

mapReduce1 :: Reducer e m => (Elem c -> e) -> c -> m #

mapTo1 :: Reducer e m => (Elem c -> e) -> m -> c -> m #

mapFrom1 :: Reducer e m => (Elem c -> e) -> c -> m -> m #

Instances

Generator1 (NonEmpty e) # |
Methods mapReduce1 :: Reducer e m => (Elem (NonEmpty e) -> e) -> NonEmpty e -> m # mapTo1 :: Reducer e m => (Elem (NonEmpty e) -> e) -> m -> NonEmpty e -> m # mapFrom1 :: Reducer e m => (Elem (NonEmpty e) -> e) -> NonEmpty e -> m -> m #

# Combinators

reduce1 :: (Generator1 c, Reducer (Elem c) m) => c -> m #

Apply a `Reducer` directly to the elements of a `Generator`

mapReduceWith1 :: (Generator1 c, Reducer e m) => (m -> n) -> (Elem c -> e) -> c -> n #

reduceWith1 :: (Generator1 c, Reducer (Elem c) m) => (m -> n) -> c -> n #