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

Copyright(c) Edward Kmett 2009-2016
LicenseBSD-style
Maintainerekmett@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

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 where Source #

minimal definition mapReduce or mapTo

Associated Types

type Elem c Source #

Methods

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

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

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

Instances

Generator ByteString Source # 

Associated Types

type Elem ByteString :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> m -> ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> ByteString -> m -> m Source #

Generator ByteString Source # 

Associated Types

type Elem ByteString :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> m -> ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem ByteString -> e) -> ByteString -> m -> m Source #

Generator IntSet Source # 

Associated Types

type Elem IntSet :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem IntSet -> e) -> IntSet -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem IntSet -> e) -> m -> IntSet -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem IntSet -> e) -> IntSet -> m -> m Source #

Generator Text Source # 

Associated Types

type Elem Text :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem Text -> e) -> Text -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem Text -> e) -> m -> Text -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem Text -> e) -> Text -> m -> m Source #

Generator [c] Source # 

Associated Types

type Elem [c] :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem [c] -> e) -> [c] -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem [c] -> e) -> m -> [c] -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem [c] -> e) -> [c] -> m -> m Source #

Generator (NonEmpty c) Source # 

Associated Types

type Elem (NonEmpty c) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (NonEmpty c) -> e) -> NonEmpty c -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (NonEmpty c) -> e) -> m -> NonEmpty c -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (NonEmpty c) -> e) -> NonEmpty c -> m -> m Source #

Generator (IntMap v) Source # 

Associated Types

type Elem (IntMap v) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (IntMap v) -> e) -> IntMap v -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (IntMap v) -> e) -> m -> IntMap v -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (IntMap v) -> e) -> IntMap v -> m -> m Source #

Generator (Seq c) Source # 

Associated Types

type Elem (Seq c) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Seq c) -> e) -> Seq c -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Seq c) -> e) -> m -> Seq c -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Seq c) -> e) -> Seq c -> m -> m Source #

Generator (Set a) Source # 

Associated Types

type Elem (Set a) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Set a) -> e) -> Set a -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Set a) -> e) -> m -> Set a -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Set a) -> e) -> Set a -> m -> m Source #

Generator (HashSet a) Source # 

Associated Types

type Elem (HashSet a) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (HashSet a) -> e) -> HashSet a -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (HashSet a) -> e) -> m -> HashSet a -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (HashSet a) -> e) -> HashSet a -> m -> m Source #

Generator (Char8 ByteString) Source # 

Associated Types

type Elem (Char8 ByteString) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> m -> Char8 ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m -> m Source #

Generator (Char8 ByteString) Source # 

Associated Types

type Elem (Char8 ByteString) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> m -> Char8 ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m -> m Source #

Generator (Values (Array i e)) Source # 

Associated Types

type Elem (Values (Array i e)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> Values (Array i e) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> m -> Values (Array i e) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> Values (Array i e) -> m -> m Source #

Generator (Values (IntMap v)) Source # 

Associated Types

type Elem (Values (IntMap v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> Values (IntMap v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> m -> Values (IntMap v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> Values (IntMap v) -> m -> m Source #

Generator (Values (Map k v)) Source # 

Associated Types

type Elem (Values (Map k v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> Values (Map k v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> m -> Values (Map k v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> Values (Map k v) -> m -> m Source #

Ix i => Generator (Keys (Array i e)) Source # 

Associated Types

type Elem (Keys (Array i e)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> Keys (Array i e) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> m -> Keys (Array i e) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> Keys (Array i e) -> m -> m Source #

Generator (Keys (IntMap v)) Source # 

Associated Types

type Elem (Keys (IntMap v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> Keys (IntMap v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> m -> Keys (IntMap v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> Keys (IntMap v) -> m -> m Source #

Generator (Keys (Map k v)) Source # 

Associated Types

type Elem (Keys (Map k v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> Keys (Map k v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> m -> Keys (Map k v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> Keys (Map k v) -> m -> m Source #

Ix i => Generator (Array i e) Source # 

Associated Types

type Elem (Array i e) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Array i e) -> e) -> Array i e -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Array i e) -> e) -> m -> Array i e -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Array i e) -> e) -> Array i e -> m -> m Source #

Generator (Map k v) Source # 

Associated Types

type Elem (Map k v) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Map k v) -> e) -> Map k v -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Map k v) -> e) -> m -> Map k v -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Map k v) -> e) -> Map k v -> m -> m Source #

Generator (FingerTree v e) Source # 

Associated Types

type Elem (FingerTree v e) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (FingerTree v e) -> e) -> FingerTree v e -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (FingerTree v e) -> e) -> m -> FingerTree v e -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (FingerTree v e) -> e) -> FingerTree v e -> m -> m Source #

Generator (HashMap k v) Source # 

Associated Types

type Elem (HashMap k v) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (HashMap k v) -> e) -> HashMap k v -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (HashMap k v) -> e) -> m -> HashMap k v -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (HashMap k v) -> e) -> HashMap k v -> m -> m Source #

Generator Transformers

newtype Keys c Source #

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

Constructors

Keys 

Fields

Instances

Ix i => Generator (Keys (Array i e)) Source # 

Associated Types

type Elem (Keys (Array i e)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> Keys (Array i e) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> m -> Keys (Array i e) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (Array i e)) -> e) -> Keys (Array i e) -> m -> m Source #

Generator (Keys (IntMap v)) Source # 

Associated Types

type Elem (Keys (IntMap v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> Keys (IntMap v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> m -> Keys (IntMap v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (IntMap v)) -> e) -> Keys (IntMap v) -> m -> m Source #

Generator (Keys (Map k v)) Source # 

Associated Types

type Elem (Keys (Map k v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> Keys (Map k v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> m -> Keys (Map k v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Keys (Map k v)) -> e) -> Keys (Map k v) -> m -> m Source #

type Elem (Keys (Array i e)) Source # 
type Elem (Keys (Array i e)) = i
type Elem (Keys (IntMap v)) Source # 
type Elem (Keys (IntMap v)) = Int
type Elem (Keys (Map k v)) Source # 
type Elem (Keys (Map k v)) = k

newtype Values c Source #

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

Constructors

Values 

Fields

Instances

Generator (Values (Array i e)) Source # 

Associated Types

type Elem (Values (Array i e)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> Values (Array i e) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> m -> Values (Array i e) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (Array i e)) -> e) -> Values (Array i e) -> m -> m Source #

Generator (Values (IntMap v)) Source # 

Associated Types

type Elem (Values (IntMap v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> Values (IntMap v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> m -> Values (IntMap v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (IntMap v)) -> e) -> Values (IntMap v) -> m -> m Source #

Generator (Values (Map k v)) Source # 

Associated Types

type Elem (Values (Map k v)) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> Values (Map k v) -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> m -> Values (Map k v) -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Values (Map k v)) -> e) -> Values (Map k v) -> m -> m Source #

type Elem (Values (Array i e)) Source # 
type Elem (Values (Array i e)) = e
type Elem (Values (IntMap v)) Source # 
type Elem (Values (IntMap v)) = v
type Elem (Values (Map k v)) Source # 
type Elem (Values (Map k v)) = v

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

Instances

Generator (Char8 ByteString) Source # 

Associated Types

type Elem (Char8 ByteString) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> m -> Char8 ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m -> m Source #

Generator (Char8 ByteString) Source # 

Associated Types

type Elem (Char8 ByteString) :: * Source #

Methods

mapReduce :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m Source #

mapTo :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> m -> Char8 ByteString -> m Source #

mapFrom :: (Reducer e m, Monoid m) => (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m -> m Source #

type Elem (Char8 ByteString) Source # 
type Elem (Char8 ByteString) Source # 

Combinators

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

Apply a Reducer directly to the elements of a Generator

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

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