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

Portabilityportable
Stabilityexperimental
Maintainerekmett@gmail.com
Safe HaskellTrustworthy

Data.Generator

Contents

Description

A Generator 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.

Since a Generator is not polymorphic in its contents, it is more specialized than Data.Foldable.Foldable, and a Reducer may supply efficient left-to-right and right-to-left reduction strategies that a Generator may avail itself of.

Synopsis

Generators

class Generator c whereSource

minimal definition mapReduce or mapTo

Associated Types

type Elem c Source

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem c -> e) -> c -> mSource

mapTo :: (Reducer e m, Monoid m) => (Elem c -> e) -> m -> c -> mSource

mapFrom :: (Reducer e m, Monoid m) => (Elem c -> e) -> c -> m -> mSource

Generator Transformers

newtype Keys c Source

a Generator transformer that asks only for the keys of an indexed container

Constructors

Keys 

Fields

getKeys :: c
 

Instances

Ix i => Generator (Keys (Array i e)) 
Generator (Keys (IntMap v)) 
Generator (Keys (Map k v)) 

newtype Values c Source

a Generator transformer that asks only for the values contained in an indexed container

Constructors

Values 

Fields

getValues :: c
 

Instances

newtype Char8 c Source

a Generator transformer that treats Word8 as Char This lets you use a ByteString as a Char source without going through a Monoid transformer like UTF8

Constructors

Char8 

Fields

getChar8 :: c
 

Combinators

reduce :: (Generator c, Reducer (Elem c) m, Monoid m) => c -> mSource

Apply a Reducer directly to the elements of a Generator

mapReduceWith :: (Generator c, Reducer e m, Monoid m) => (m -> n) -> (Elem c -> e) -> c -> nSource

reduceWith :: (Generator c, Reducer (Elem c) m, Monoid m) => (m -> n) -> c -> nSource