Utilities for working with Monoids that conflict with names from the Prelude,
+ Data.Foldable, Control.Monad or elsewhere. Intended to be imported qualified.
+
Compression algorithms are all about exploiting redundancy. When applying
+ an expensive Reducer to a redundant source, it may be better to
+ extract the structural redundancy that is present. LZ78 is a compression
+ algorithm that does so, without requiring the dictionary to be populated
+ with all of the possible values of a data type unlike its later
+ refinement LZW, and which has fewer comparison reqirements during encoding
+ than its earlier counterpart LZ77. Since we aren't storing these as a
+ bitstream the LZSS refinement of only encoding pointers once you cross
+ the break-even point is a net loss.
+
Compression algorithms are all about exploiting redundancy. When applying
+ an expensive Reducer to a redundant source, it may be better to
+ extract the structural redundancy that is present. Run length encoding
+ can do so for long runs of identical inputs.
+
A Generatorc is a possibly-specialized container, which contains values of
+ type Elemc, 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.
+
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
+
hunk ./doc/html/monoids/Data-Group-Combinators.html 22
->monoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkMonadic Reduction
-
CoArbitrary a => CoArbitrary (FromNummonoids-0.1.24: Monoids, specialized containers and a general map/reduce framework
monoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce framework(Arbitrary r, Arbitrary m) => Arbitrary (D s r m)
(CoArbitrary r, CoArbitrary m) => CoArbitrary (D s r m)
monoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce framework ( ( ( ( ( (Eq a => ModuleNatural (RLESeq a)
monoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.24: Monoids, specialized containers and a general map/reduce frameworkmonoids-0.1.25: Monoids, specialized containers and a general map/reduce frameworkArbitrary a => Arbitrary (Order a)
{-# LANGUAGE UndecidableInstances, TypeOperators, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances, TypeFamilies #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Generator.Combinators
+-- Copyright : (c) Edward Kmett 2009
+-- License : BSD-style
+-- Maintainer : ekmett@gmail.com
+-- Stability : experimental
+-- Portability : non-portable (type families, MPTCs)
+--
+-- Utilities for working with Monoids that conflict with names from the "Prelude",
+-- "Data.Foldable", "Control.Monad" or elsewhere. Intended to be imported qualified.
+--
+-- > import Data.Generator.Combinators as Generator
+--
+-----------------------------------------------------------------------------
+
+moduleData.Generator.Combinators
+(moduleData.Generator
+-- * Monadic Reduction
+,mapM_
+,forM_
+,msum
+-- * Applicative Reduction
+,traverse_
+,for_
+,asum
+-- * Logical Reduction
+,and
+,or
+,any
+,all
+-- * Monoidal Reduction
+,foldMap
+,fold
+,toList
+-- * List-Like Reduction
+,concatMap
+,elem
+,filter
+,filterWith
+,find
+,sum
+,product
+,notElem
+)where
+
+importPreludehiding(mapM_,any,elem,filter,concatMap,and,or,all,sum,product,notElem,replicate,cycle,repeat)
+importControl.Applicative
+importControl.Monad(MonadPlus)
+importData.Generator
+importData.Monoid.Applicative
+importData.Monoid.Self
+importData.Monoid.Monad
+
+-- | Efficiently 'mapReduce' a 'Generator' using the 'Traversal' monoid. A specialized version of its namesake from "Data.Foldable"
+--
+-- @
+-- 'mapReduce' 'getTraversal'
+-- @
+traverse_::(Generatorc,Applicativef)=>(Elemc->fb)->c->f()
+traverse_=mapReduceWithgetTraversal
+{-# INLINE traverse_ #-}
+
+-- | Convenience function as found in "Data.Foldable"
+--
+-- @
+-- 'flip' 'traverse_'
+-- @
+for_::(Generatorc,Applicativef)=>c->(Elemc->fb)->f()
+for_=fliptraverse_
+{-# INLINE for_ #-}
+
+-- | The sum of a collection of actions, generalizing 'concat'
+--
+-- @
+-- 'reduceWith' 'getAlt'
+-- @
+asum::(Generatorc,Alternativef,fa~Elemc)=>c->fa
+asum=reduceWithgetAlt
+{-# INLINE asum #-}
+
+-- | Efficiently 'mapReduce' a 'Generator' using the 'Action' monoid. A specialized version of its namesake from "Data.Foldable" and "Control.Monad"
+--
+-- @
+-- 'mapReduceWith' 'getAction'
+-- @
+mapM_::(Generatorc,Monadm)=>(Elemc->mb)->c->m()
+mapM_=mapReduceWithgetAction
+{-# INLINE mapM_ #-}
+
+-- | Convenience function as found in "Data.Foldable" and "Control.Monad"
+--
+-- @
+-- 'flip' 'mapM_'
+-- @
+forM_::(Generatorc,Monadm)=>c->(Elemc->mb)->m()
+forM_=flipmapM_
+{-# INLINE forM_ #-}
+
+-- | The sum of a collection of actions, generalizing 'concat'
+--
+-- @
+-- 'reduceWith' 'getMonadSum'
+-- @
+msum::(Generatorc,MonadPlusm,ma~Elemc)=>c->ma
+msum=reduceWithgetMonadSum
+{-# INLINE msum #-}
+
+-- | Efficiently 'mapReduce' a 'Generator' using the 'Self' monoid. A specialized version of its namesake from "Data.Foldable"
+--
+-- @
+-- 'mapReduceWith' 'getSelf'
+-- @
+foldMap::(Monoidm,Generatorc)=>(Elemc->m)->c->m
+foldMap=mapReduceWithgetSelf
+{-# INLINE foldMap #-}
+
+-- | Type specialization of "foldMap" above
+concatMap::Generatorc=>(Elemc->[b])->c->[b]
+concatMap=foldMap
+{-# INLINE concatMap #-}
+
+-- | Efficiently 'reduce' a 'Generator' using the 'Self' monoid. A specialized version of its namesake from "Data.Foldable"
+--
+-- @
+-- 'reduceWith' 'getSelf'
+-- @
+fold::(Monoidm,Generatorc,Elemc~m)=>c->m
+fold=reduceWithgetSelf
+{-# INLINE fold #-}
+
+-- | Convert any 'Generator' to a list of its contents. Specialization of 'reduce'
+toList::Generatorc=>c->[Elemc]
+toList=reduce
+{-# INLINE toList #-}
+
+-- | Efficiently 'reduce' a 'Generator' that contains values of type 'Bool'
+--
+-- @
+-- 'reduceWith' 'getAll'
+-- @
+and::(Generatorc,Elemc~Bool)=>c->Bool
+and=reduceWithgetAll
+{-# INLINE and #-}
+
+-- | Efficiently 'reduce' a 'Generator' that contains values of type 'Bool'
+--
+-- @
+-- 'reduceWith' 'getAny'
+-- @
+or::(Generatorc,Elemc~Bool)=>c->Bool
+or=reduceWithgetAny
+{-# INLINE or #-}
+
+-- | Efficiently 'mapReduce' any 'Generator' checking to see if any of its values match the supplied predicate
+--
+-- @
+-- 'mapReduceWith' 'getAny'
+-- @
+any::Generatorc=>(Elemc->Bool)->c->Bool
+any=mapReduceWithgetAny
+{-# INLINE any #-}
+
+-- | Efficiently 'mapReduce' any 'Generator' checking to see if all of its values match the supplied predicate
+--
+-- @
+-- 'mapReduceWith' 'getAll'
+-- @
+all::Generatorc=>(Elemc->Bool)->c->Bool
+all=mapReduceWithgetAll
+{-# INLINE all #-}
+
+-- | Efficiently sum over the members of any 'Generator'
+--
+-- @
+-- 'reduceWith' 'getSum'
+-- @
+sum::(Generatorc,Num(Elemc))=>c->Elemc
+sum=reduceWithgetSum
+{-# INLINE sum #-}
+
+-- | Efficiently take the product of every member of a 'Generator'
+--
+-- @
+-- 'reduceWith' 'getProduct'
+-- @
+product::(Generatorc,Num(Elemc))=>c->Elemc
+product=reduceWithgetProduct
+{-# INLINE product #-}
+
+-- | Check to see if 'any' member of the 'Generator' matches the supplied value
+elem::(Generatorc,Eq(Elemc))=>Elemc->c->Bool
+elem=any.(==)
+{-# INLINE elem #-}
+
+-- | Check to make sure that the supplied value is not a member of the 'Generator'
+notElem::(Generatorc,Eq(Elemc))=>Elemc->c->Bool
+notElemx=not.elemx
+{-# INLINE notElem #-}
+
+-- | Efficiently 'mapReduce' a subset of the elements in a 'Generator'
+filter::(Generatorc,Elemc`Reducer`m)=>(Elemc->Bool)->c->m
+filterp=foldMapfwhere
+fx|px=unitx
+|otherwise=mempty
+{-# INLINE filter #-}
+
+-- | Allows idiomatic specialization of filter by proving a function that will be used to transform the output
+filterWith::(Generatorc,Elemc`Reducer`m)=>(m->n)->(Elemc->Bool)->c->n
+filterWithfp=f.filterp
+{-# INLINE filterWith #-}
+
+-- | A specialization of 'filter' using the 'First' 'Monoid', analogous to 'Data.List.find'
+--
+-- @
+-- 'filterWith' 'getFirst'
+-- @
+find::Generatorc=>(Elemc->Bool)->c->Maybe(Elemc)
+find=filterWithgetFirst
+{-# INLINE find #-}
+
+
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Generator.Compressive.LZ78
+-- Copyright : (c) Edward Kmett 2009
+-- License : BSD-style
+-- Maintainer : ekmett@gmail.com
+-- Stability : experimental
+-- Portability : portable
+--
+-- Compression algorithms are all about exploiting redundancy. When applying
+-- an expensive 'Reducer' to a redundant source, it may be better to
+-- extract the structural redundancy that is present. 'LZ78' is a compression
+-- algorithm that does so, without requiring the dictionary to be populated
+-- with all of the possible values of a data type unlike its later
+-- refinement LZW, and which has fewer comparison reqirements during encoding
+-- than its earlier counterpart LZ77. Since we aren't storing these as a
+-- bitstream the LZSS refinement of only encoding pointers once you cross
+-- the break-even point is a net loss.
+-----------------------------------------------------------------------------
+
+
+moduleData.Generator.Compressive.LZ78
+(moduleData.Generator
+-- * Lempel-Ziv 78
+,LZ78
+-- * Decoding
+,decode
+-- * Encoding
+,encode
+,encodeEq
+-- * QuickCheck Properties
+,prop_decode_encode
+,prop_decode_encodeEq
+)where
+
+importqualifiedData.SequenceasSeq
+importData.Sequence(Seq,(|>))
+importqualifiedData.MapasMap
+importData.Map(Map)
+importqualifiedData.ListasList
+importData.Generator
+importData.Foldable
+importData.Monoid.Self
+
+-- | An LZ78 compressing 'Generator', which supports efficient 'mapReduce' operations
+
+dataTokena=Tokena{-# UNPACK #-}!Int
+deriving(Eq,Ord,Show,Read)
+
+-- after using the Functor instance the encoding may no longer be minimal
+instanceFunctorTokenwhere
+fmapf(Tokenan)=Token(fa)n
+
+newtypeLZ78a=LZ78{getLZ78::[Tokena]}
+deriving(Eq,Ord,Show)
+
+emptyDict::Monoidm=>Seqm
+emptyDict=Seq.singletonmempty
+
+instanceGenerator(LZ78a)where
+typeElem(LZ78a)=a
+mapTofm(LZ78xs)=mapTo'fmemptyDictxs
+
+instanceFunctorLZ78where
+fmapf=LZ78.fmap(fmapf).getLZ78
+
+instanceFoldableLZ78where
+foldMapf=getSelf.mapReducef
+fold=getSelf.reduce
+
+mapTo'::(e`Reducer`m)=>(a->e)->m->Seqm->[Tokena]->m
+mapTo'_m_[]=m
+mapTo'fms(Tokencw:ws)=m`mappend`mapTo'fv(s|>v)ws
+where
+v=Seq.indexsw`mappend`unit(fc)
+
+-- | a type-constrained 'reduce' operation
+
+decode::LZ78a->[a]
+decode=reduce
+
+-- | contruct an LZ78-compressed 'Generator' using a 'Map' internally, requires an instance of Ord.
+
+encode::Orda=>[a]->LZ78a
+encode=LZ78.encode'Map.empty10
+
+encode'::Orda=>Map(Tokena)Int->Int->Int->[a]->[Tokena]
+encode'__p[c]=[Tokencp]
+encode'dfp(c:cs)=lett=TokencpincaseMap.lookuptdof
+Justp'->encode'dfp'cs
+Nothing->t:encode'(Map.inserttfd)(succf)0cs
+encode'___[]=[]
+
+-- | contruct an LZ78-compressed 'Generator' using a list internally, requires an instance of Eq.
+
+encodeEq::Eqa=>[a]->LZ78a
+encodeEq=LZ78.encodeEq'[]10
+
+encodeEq'::Eqa=>[(Tokena,Int)]->Int->Int->[a]->[Tokena]
+encodeEq'__p[c]=[Tokencp]
+encodeEq'dfp(c:cs)=lett=TokencpincaseList.lookuptdof
+Justp'->encodeEq'dfp'cs
+Nothing->t:encodeEq'((t,f):d)(succf)0cs
+encodeEq'___[]=[]
+
+-- | QuickCheck property: decode . encode = id
+prop_decode_encode::Orda=>[a]->Bool
+prop_decode_encodexs=decode(encodexs)==xs
+
+-- | QuickCheck property: decode . encodeEq = id
+prop_decode_encodeEq::Eqa=>[a]->Bool
+prop_decode_encodeEqxs=decode(encodeEqxs)==xs
+
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, TypeOperators, FlexibleInstances, FlexibleContexts #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Generator.Compressive.RLE
+-- Copyright : (c) Edward Kmett 2009
+-- License : BSD-style
+-- Maintainer : ekmett@gmail.com
+-- Stability : experimental
+-- Portability : portable
+--
+-- Compression algorithms are all about exploiting redundancy. When applying
+-- an expensive 'Reducer' to a redundant source, it may be better to
+-- extract the structural redundancy that is present. Run length encoding
+-- can do so for long runs of identical inputs.
+-----------------------------------------------------------------------------
+
+moduleData.Generator.Compressive.RLE
+(moduleData.Generator
+,RLE(RLE,getRLE)
+,Run(Run)
+,decode
+,encode
+,encodeList
+,prop_decode_encode
+,prop_decode_encodeList
+)where
+
+importqualifiedData.SequenceasSeq
+importData.Sequence(Seq,(|>),(<|),ViewL(..),ViewR(..),(><),viewl,viewr)
+importData.Foldable
+importData.Generator
+importqualifiedData.Monoid.CombinatorsasMonoid
+importControl.Functor.Pointed
+
+-- | A single run with a strict length.
+dataRuna=Runa{-# UNPACK #-}!Int
+
+instanceFunctorRunwhere
+fmapf(Runan)=Run(fa)n
+
+instancePointedRunwhere
+pointa=Runa1
+
+-- | A 'Generator' which supports efficient 'mapReduce' operations over run-length encoded data.
+newtypeRLEfa=RLE{getRLE::f(Runa)}
+
+instanceFunctorf=>Functor(RLEf)where
+fmapf=RLE.fmap(fmapf).getRLE
+
+instanceFoldablef=>Generator(RLEfa)where
+typeElem(RLEfa)=a
+mapReducef=foldMaprun.getRLEwhere
+run(Runan)=unit(fa)`Monoid.replicate`n
+
+decode::Foldablef=>RLEfa->[a]
+decode=reduce
+
+-- | naive left to right encoder, which can handle infinite data
+
+encodeList::Eqa=>[a]->RLE[]a
+encodeList[]=RLE[]
+encodeList(a:as)=RLE(pointa`before`as)
+
+before::Eqa=>Runa->[a]->[Runa]
+r`before`[]=[r]
+r@(Runan)`before`(b:bs)|a==b=Runa(n+1)`before`bs
+|otherwise=r:pointb`before`bs
+
+-- | QuickCheck property: decode . encode = id
+prop_decode_encodeList::Eqa=>[a]->Bool
+prop_decode_encodeListxs=decode(encodexs)==xs
+
+-- One nice property that run-length encoding has is that it can be computed monoidally as follows
+-- However, this monoid cannot be used to handle infinite sources.
+
+instanceEqa=>Monoid(RLESeqa)where
+mempty=RLESeq.empty
+RLEl`mappend`RLEr=viewrl`merge`viewlrwhere
+(l':>Runam)`merge`(Runbn:<r')
+|a==b=RLE((l'|>Runa(m+n))><r')
+|otherwise=RLE(l><r)
+EmptyR`merge`_=RLEr
+_`merge`EmptyL=RLEl
+
+instanceEqa=>Reducera(RLESeqa)where
+unit=RLE.Seq.singleton.point
+consa(RLEr)=caseviewlrof
+Runbn:<r'|a==b->RLE(Runa(n+1)<|r')
+|otherwise->RLE(Runa1<|r)
+EmptyL->RLE(return(pointa))
+snoc(RLEl)a=caseviewrlof
+l':>Runbn|a==b->RLE(l'|>Runb(n+1))
+|otherwise->RLE(l|>Runa1)
+EmptyR->RLE(return(pointa))
+
+encode::(Generatorc,Eq(Elemc))=>c->RLESeq(Elemc)
+encode=reduce
+
+prop_decode_encode::(Generatorc,Eq(Elemc))=>c->Bool
+prop_decode_encodexs=decode(encodexs)==reducexs
+
{-# LANGUAGE UndecidableInstances, TypeOperators, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances, TypeFamilies #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Generator
+-- Copyright : (c) Edward Kmett 2009
+-- License : BSD-style
+-- Maintainer : ekmett@gmail.com
+-- Stability : experimental
+-- Portability : portable
+--
+-- 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.
+-----------------------------------------------------------------------------
+
+moduleData.Generator
+(moduleData.Monoid.Reducer
+-- * Generators
+,Generator
+,Elem
+,mapReduce
+,mapTo
+,mapFrom
+-- * Generator Transformers
+,Keys(Keys,getKeys)
+,Values(Values,getValues)
+,Char8(Char8,getChar8)
+-- * Combinators
+,reduce
+,mapReduceWith
+,reduceWith
+)where
+
+importData.Array
+importData.Word(Word8)
+importData.Text(Text)
+importData.Foldable(fold,foldMap)
+importqualifiedData.TextasText
+importqualifiedData.ByteStringasStrict(ByteString,foldl')
+importqualifiedData.ByteString.Char8asStrict8(foldl')
+importqualifiedData.ByteString.LazyasLazy(ByteString,toChunks)
+importqualifiedData.ByteString.Lazy.Char8asLazy8(toChunks)
+importqualifiedData.SequenceasSeq
+importData.FingerTree(Measured,FingerTree)
+importData.Sequence(Seq)
+importqualifiedData.SetasSet
+importData.Set(Set)
+importqualifiedData.IntSetasIntSet
+importData.IntSet(IntSet)
+importqualifiedData.IntMapasIntMap
+importData.IntMap(IntMap)
+importqualifiedData.MapasMap
+importData.Map(Map)
+
+importControl.Parallel.Strategies
+importData.Monoid.Reducer
+
+-- | minimal definition 'mapReduce' or 'mapTo'
+classGeneratorcwhere
+typeElemc::*
+mapReduce::(e`Reducer`m)=>(Elemc->e)->c->m
+mapTo::(e`Reducer`m)=>(Elemc->e)->m->c->m
+mapFrom::(e`Reducer`m)=>(Elemc->e)->c->m->m
+
+mapReducef=mapTofmempty
+mapTofm=mappendm.mapReducef
+mapFromf=mappend.mapReducef
+
+instanceGeneratorStrict.ByteStringwhere
+typeElemStrict.ByteString=Word8
+mapTof=Strict.foldl'(\a->snoca.f)
+
+instanceGeneratorLazy.ByteStringwhere
+typeElemLazy.ByteString=Word8
+mapReducef=fold.parMaprwhnf(mapReducef).Lazy.toChunks
+
+instanceGeneratorTextwhere
+typeElemText=Char
+mapTof=Text.foldl'(\a->snoca.f)
+
+instanceGenerator[c]where
+typeElem[c]=c
+mapReducef=foldr(cons.f)mempty
+
+instanceMeasuredve=>Generator(FingerTreeve)where
+typeElem(FingerTreeve)=e
+mapReducef=foldMap(unit.f)
+
+instanceGenerator(Seqc)where
+typeElem(Seqc)=c
+mapReducef=foldMap(unit.f)
+
+instanceGeneratorIntSetwhere
+typeElemIntSet=Int
+mapReducef=mapReducef.IntSet.toList
+
+instanceGenerator(Seta)where
+typeElem(Seta)=a
+mapReducef=mapReducef.Set.toList
+
+instanceGenerator(IntMapv)where
+typeElem(IntMapv)=(Int,v)
+mapReducef=mapReducef.IntMap.toList
+
+instanceGenerator(Mapkv)where
+typeElem(Mapkv)=(k,v)
+mapReducef=mapReducef.Map.toList
+
+instanceIxi=>Generator(Arrayie)where
+typeElem(Arrayie)=(i,e)
+mapReducef=mapReducef.assocs
+
+-- | a 'Generator' transformer that asks only for the keys of an indexed container
+newtypeKeysc=Keys{getKeys::c}
+
+instanceGenerator(Keys(IntMapv))where
+typeElem(Keys(IntMapv))=Int
+mapReducef=mapReducef.IntMap.keys.getKeys
+
+instanceGenerator(Keys(Mapkv))where
+typeElem(Keys(Mapkv))=k
+mapReducef=mapReducef.Map.keys.getKeys
+
+instanceIxi=>Generator(Keys(Arrayie))where
+typeElem(Keys(Arrayie))=i
+mapReducef=mapReducef.range.bounds.getKeys
+
+-- | a 'Generator' transformer that asks only for the values contained in an indexed container
+newtypeValuesc=Values{getValues::c}
+
+instanceGenerator(Values(IntMapv))where
+typeElem(Values(IntMapv))=v
+mapReducef=mapReducef.IntMap.elems.getValues
+
+instanceGenerator(Values(Mapkv))where
+typeElem(Values(Mapkv))=v
+mapReducef=mapReducef.Map.elems.getValues
+
+instanceIxi=>Generator(Values(Arrayie))where
+typeElem(Values(Arrayie))=e
+mapReducef=mapReducef.elems.getValues
+
+-- | 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'
+newtypeChar8c=Char8{getChar8::c}
+
+instanceGenerator(Char8Strict.ByteString)where
+typeElem(Char8Strict.ByteString)=Char
+mapTofm=Strict8.foldl'(\a->snoca.f)m.getChar8
+
+instanceGenerator(Char8Lazy.ByteString)where
+typeElem(Char8Lazy.ByteString)=Char
+mapReducef=fold.parMaprwhnf(mapReducef.Char8).Lazy8.toChunks.getChar8
+
+-- | Apply a 'Reducer' directly to the elements of a 'Generator'
+reduce::(Generatorc,Elemc`Reducer`m)=>c->m
+reduce=mapReduceid
+{-# SPECIALIZE reduce :: (Word8 `Reducer` m) => Strict.ByteString -> m #-}
+{-# SPECIALIZE reduce :: (Word8 `Reducer` m) => Lazy.ByteString -> m #-}
+{-# SPECIALIZE reduce :: (Char `Reducer` m) => Char8 Strict.ByteString -> m #-}
+{-# SPECIALIZE reduce :: (Char `Reducer` m) => Char8 Lazy.ByteString -> m #-}
+{-# SPECIALIZE reduce :: (c `Reducer` m) => [c] -> m #-}
+{-# SPECIALIZE reduce :: (Generator (FingerTree v e), e `Reducer` m) => FingerTree v e -> m #-}
+{-# SPECIALIZE reduce :: (Char `Reducer` m) => Text -> m #-}
+{-# SPECIALIZE reduce :: (e `Reducer` m) => Seq e -> m #-}
+{-# SPECIALIZE reduce :: (Int `Reducer` m) => IntSet -> m #-}
+{-# SPECIALIZE reduce :: (a `Reducer` m) => Set a -> m #-}
+{-# SPECIALIZE reduce :: ((Int,v) `Reducer` m) => IntMap v -> m #-}
+{-# SPECIALIZE reduce :: ((k,v) `Reducer` m) => Map k v -> m #-}
+{-# SPECIALIZE reduce :: (Int `Reducer` m) => Keys (IntMap v) -> m #-}
+{-# SPECIALIZE reduce :: (k `Reducer` m) => Keys (Map k v) -> m #-}
+{-# SPECIALIZE reduce :: (v `Reducer` m) => Values (IntMap v) -> m #-}
+{-# SPECIALIZE reduce :: (v `Reducer` m) => Values (Map k v) -> m #-}
+
+mapReduceWith::(Generatorc,e`Reducer`m)=>(m->n)->(Elemc->e)->c->n
+mapReduceWithfg=f.mapReduceg
+{-# INLINE mapReduceWith #-}
+
+reduceWith::(Generatorc,Elemc`Reducer`m)=>(m->n)->c->n
+reduceWithf=f.reduce
+{-# INLINE reduceWith #-}
+
+
hunk ./doc/html/monoids/src/Data-Monoid-Combinators.html 23
--- > import Data.Group.Combinators as Monoid
+-- > import Data.Monoid.Combinators as Monoid
hunk ./doc/html/monoids/src/Data-Monoid-Combinators.html 28
-(moduleData.Monoid.Generator
--- * Monadic Reduction
-,mapM_
-,forM_
-,msum
--- * Applicative Reduction
-,traverse_
-,for_
-,asum
--- * Logical Reduction
-,and
-,or
-,any
-,all
--- * Monoidal Reduction
-,foldMap
-,fold
-,toList
--- * List-Like Reduction
-,concatMap
-,elem
-,filter
-,filterWith
-,find
-,sum
-,product
-,notElem
--- * List-Like Monoid Production
-,repeat
-,replicate
-,cycle
--- * QuickCheck Properties
-,prop_replicate_right_distributive
-)where
-
-importPreludehiding(mapM_,any,elem,filter,concatMap,and,or,all,sum,product,notElem,replicate,cycle,repeat)
-importControl.Applicative
-importControl.Monad(MonadPlus)
-importData.Monoid.Generator
-importData.Monoid.Applicative
-importData.Monoid.Self
-importData.Monoid.Monad
-importTest.QuickCheck
-
--- | Efficiently 'mapReduce' a 'Generator' using the 'Traversal' monoid. A specialized version of its namesake from "Data.Foldable"
---
--- @
--- 'mapReduce' 'getTraversal'
--- @
-traverse_::(Generatorc,Applicativef)=>(Elemc->fb)->c->f()
-traverse_=mapReduceWithgetTraversal
-{-# INLINE traverse_ #-}
-
--- | Convenience function as found in "Data.Foldable"
---
--- @
--- 'flip' 'traverse_'
--- @
-for_::(Generatorc,Applicativef)=>c->(Elemc->fb)->f()
-for_=fliptraverse_
-{-# INLINE for_ #-}
-
--- | The sum of a collection of actions, generalizing 'concat'
---
--- @
--- 'reduceWith' 'getAlt'
--- @
-asum::(Generatorc,Alternativef,fa~Elemc)=>c->fa
-asum=reduceWithgetAlt
-{-# INLINE asum #-}
-
--- | Efficiently 'mapReduce' a 'Generator' using the 'Action' monoid. A specialized version of its namesake from "Data.Foldable" and "Control.Monad"
---
--- @
--- 'mapReduceWith' 'getAction'
--- @
-mapM_::(Generatorc,Monadm)=>(Elemc->mb)->c->m()
-mapM_=mapReduceWithgetAction
-{-# INLINE mapM_ #-}
-
--- | Convenience function as found in "Data.Foldable" and "Control.Monad"
---
--- @
--- 'flip' 'mapM_'
--- @
-forM_::(Generatorc,Monadm)=>c->(Elemc->mb)->m()
-forM_=flipmapM_
-{-# INLINE forM_ #-}
-
--- | The sum of a collection of actions, generalizing 'concat'
---
--- @
--- 'reduceWith' 'getMonadSum'
--- @
-msum::(Generatorc,MonadPlusm,ma~Elemc)=>c->ma
-msum=reduceWithgetMonadSum
-{-# INLINE msum #-}
-
--- | Efficiently 'mapReduce' a 'Generator' using the 'Self' monoid. A specialized version of its namesake from "Data.Foldable"
---
--- @
--- 'mapReduceWith' 'getSelf'
--- @
-foldMap::(Monoidm,Generatorc)=>(Elemc->m)->c->m
-foldMap=mapReduceWithgetSelf
-{-# INLINE foldMap #-}
-
--- | Type specialization of "foldMap" above
-concatMap::Generatorc=>(Elemc->[b])->c->[b]
-concatMap=foldMap
-{-# INLINE concatMap #-}
-
--- | Efficiently 'reduce' a 'Generator' using the 'Self' monoid. A specialized version of its namesake from "Data.Foldable"
---
--- @
--- 'reduceWith' 'getSelf'
--- @
-fold::(Monoidm,Generatorc,Elemc~m)=>c->m
-fold=reduceWithgetSelf
-{-# INLINE fold #-}
-
--- | Convert any 'Generator' to a list of its contents. Specialization of 'reduce'
-toList::Generatorc=>c->[Elemc]
-toList=reduce
-{-# INLINE toList #-}
-
--- | Efficiently 'reduce' a 'Generator' that contains values of type 'Bool'
---
--- @
--- 'reduceWith' 'getAll'
--- @
-and::(Generatorc,Elemc~Bool)=>c->Bool
-and=reduceWithgetAll
-{-# INLINE and #-}
-
--- | Efficiently 'reduce' a 'Generator' that contains values of type 'Bool'
---
--- @
--- 'reduceWith' 'getAny'
--- @
-or::(Generatorc,Elemc~Bool)=>c->Bool
-or=reduceWithgetAny
-{-# INLINE or #-}
-
--- | Efficiently 'mapReduce' any 'Generator' checking to see if any of its values match the supplied predicate
---
--- @
--- 'mapReduceWith' 'getAny'
--- @
-any::Generatorc=>(Elemc->Bool)->c->Bool
-any=mapReduceWithgetAny
-{-# INLINE any #-}
-
--- | Efficiently 'mapReduce' any 'Generator' checking to see if all of its values match the supplied predicate
---
--- @
--- 'mapReduceWith' 'getAll'
--- @
-all::Generatorc=>(Elemc->Bool)->c->Bool
-all=mapReduceWithgetAll
-{-# INLINE all #-}
-
--- | Efficiently sum over the members of any 'Generator'
---
--- @
--- 'reduceWith' 'getSum'
--- @
-sum::(Generatorc,Num(Elemc))=>c->Elemc
-sum=reduceWithgetSum
-{-# INLINE sum #-}
-
--- | Efficiently take the product of every member of a 'Generator'
---
--- @
--- 'reduceWith' 'getProduct'
--- @
-product::(Generatorc,Num(Elemc))=>c->Elemc
-product=reduceWithgetProduct
-{-# INLINE product #-}
-
--- | Check to see if 'any' member of the 'Generator' matches the supplied value
-elem::(Generatorc,Eq(Elemc))=>Elemc->c->Bool
-elem=any.(==)
-{-# INLINE elem #-}
-
--- | Check to make sure that the supplied value is not a member of the 'Generator'
-notElem::(Generatorc,Eq(Elemc))=>Elemc->c->Bool
-notElemx=not.elemx
-{-# INLINE notElem #-}
-
--- | Efficiently 'mapReduce' a subset of the elements in a 'Generator'
-filter::(Generatorc,Elemc`Reducer`m)=>(Elemc->Bool)->c->m
-filterp=foldMapfwhere
-fx|px=unitx
-|otherwise=mempty
-{-# INLINE filter #-}
-
--- | Allows idiomatic specialization of filter by proving a function that will be used to transform the output
-filterWith::(Generatorc,Elemc`Reducer`m)=>(m->n)->(Elemc->Bool)->c->n
-filterWithfp=f.filterp
-{-# INLINE filterWith #-}
-
--- | A specialization of 'filter' using the 'First' 'Monoid', analogous to 'Data.List.find'
---
--- @
--- 'filterWith' 'getFirst'
--- @
-find::Generatorc=>(Elemc->Bool)->c->Maybe(Elemc)
-find=filterWithgetFirst
-{-# INLINE find #-}
-
--- | A generalization of 'Data.List.replicate' to an arbitrary 'Monoid'. Adapted from
--- <http://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html>
-replicate::(Monoidm,Integraln)=>m->n->m
-replicatex0y0
-|y0<0=mempty-- error "negative length"
-|y0==0=mempty
-|otherwise=fx0y0
-where
-fxy
-|eveny=f(x`mappend`x)(y`quot`2)
-|y==1=x
-|otherwise=g(x`mappend`x)((y-1)`quot`2)x
-gxyz
-|eveny=g(x`mappend`x)(y`quot`2)z
-|y==1=x`mappend`z
-|otherwise=g(x`mappend`x)((y-1)`quot`2)(x`mappend`z)
-{-# INLINE replicate #-}
-
--- | A generalization of 'Data.List.cycle' to an arbitrary 'Monoid'. May fail to terminate for some values in some monoids.
-cycle::Monoidm=>m->m
-cyclexs=xs'wherexs'=xs`mappend`xs'
-
--- | A generalization of 'Data.List.repeat' to an arbitrary 'Monoid'. May fail to terminate for some values in some monoids.
-repeat::(e`Reducer`m)=>e->m
-repeatx=xswherexs=consxxs
-
-prop_replicate_right_distributive::(Eqm,Monoidm,Arbitrarym,Integraln)=>m->n->n->Bool
-prop_replicate_right_distributivemxy
-=replicatem(x+y)==replicatemx`mappend`replicatemy
+(
+-- * List-Like Monoid Production
+repeat
+,replicate
+,cycle
+-- * QuickCheck Properties
+,prop_replicate_right_distributive
+)where
+
+importPreludehiding(replicate,cycle,repeat)
+importControl.Monad(MonadPlus)
+importData.Monoid.Reducer
+importTest.QuickCheck
+
+
+-- | A generalization of 'Data.List.cycle' to an arbitrary 'Monoid'. May fail to terminate for some values in some monoids.
+cycle::Monoidm=>m->m
+cyclexs=xs'wherexs'=xs`mappend`xs'
+
+-- | A generalization of 'Data.List.repeat' to an arbitrary 'Monoid'. May fail to terminate for some values in some monoids.
+repeat::(e`Reducer`m)=>e->m
+repeatx=xswherexs=consxxs
+
+-- | A generalization of 'Data.List.replicate' to an arbitrary 'Monoid'. Adapted from
+-- <http://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html>
+replicate::(Monoidm,Integraln)=>m->n->m
+replicatex0y0
+|y0<0=mempty-- error "negative length"
+|y0==0=mempty
+|otherwise=fx0y0
+where
+fxy
+|eveny=f(x`mappend`x)(y`quot`2)
+|y==1=x
+|otherwise=g(x`mappend`x)((y-1)`quot`2)x
+gxyz
+|eveny=g(x`mappend`x)(y`quot`2)z
+|y==1=x`mappend`z
+|otherwise=g(x`mappend`x)((y-1)`quot`2)(x`mappend`z)
+{-# INLINE replicate #-}
+
+prop_replicate_right_distributive::(Eqm,Monoidm,Arbitrarym,Integraln)=>m->n->n->Bool
+prop_replicate_right_distributivemxy
+=replicatem(x+y)==replicatemx`mappend`replicatemy
hunk ./doc/html/monoids/src/Data-Monoid-FromString.html 31
-importData.Monoid.Generator
+importData.Generator
hunk ./doc/html/monoids/src/Data-Monoid-Lexical-SourcePosition.html 44
-importData.Monoid.Generator
+importData.Generator
hunk ./doc/html/monoids/src/Data-Monoid-Lexical-Words.html 44
-importData.Monoid.Generator
+importData.Generator
hunk ./doc/html/monoids/src/Data-Monoid-Multiplicative.html 76
-importData.Monoid.Generator
+importData.Generator
hunk ./doc/html/monoids/src/Data-Monoid-Self.html 36
-importData.Monoid.Generator
+importData.Generator
hunk ./doc/html/monoids/src/Data-Ring-Semi-Natural.html 46
-importData.Monoid.Generator.Free
-importData.Monoid.Generator.RLE
+importData.Generator.Free
+importData.Generator.Compressive.RLE
hunk ./doc/html/monoids/src/Data-Ring-Semi-Near.html 49
-importData.Monoid.Generator
+importData.Generator
}