{-# LANGUAGE UndecidableInstances, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances, TypeFamilies, CPP #-}
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
#endif
module Data.Generator
(
Generator(..)
, Keys(Keys, getKeys)
, Values(Values, getValues)
, Char8(Char8, getChar8)
, reduce
, mapReduceWith
, reduceWith
) where
#if __GLASGOW_HASKELL__ < 710
import Data.Monoid (Monoid, mappend, mempty)
#endif
import Data.Array
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.ByteString as Strict (ByteString, foldl')
import qualified Data.ByteString.Char8 as Strict8 (foldl')
import qualified Data.ByteString.Lazy as Lazy (ByteString, toChunks)
import qualified Data.ByteString.Lazy.Char8 as Lazy8 (toChunks)
import Data.Word (Word8)
import Data.FingerTree (FingerTree)
import Data.Sequence (Seq)
import qualified Data.Set as Set
import Data.Set (Set)
import qualified Data.IntSet as IntSet
import Data.IntSet (IntSet)
import qualified Data.IntMap as IntMap
import Data.IntMap (IntMap)
import qualified Data.HashSet as HashSet
import Data.HashSet (HashSet)
import qualified Data.HashMap.Lazy as HashMap
import Data.HashMap.Lazy (HashMap)
import qualified Data.Map as Map
import Data.Map (Map)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.List.NonEmpty as NonEmpty
#if __GLASGOW_HASKELL__ < 710
import Data.Foldable (fold,foldMap)
#else
import Data.Foldable (fold)
#endif
import Data.Semigroup.Reducer
class Generator c where
type Elem c
mapReduce :: (Reducer e m, Monoid m) => (Elem c -> e) -> c -> m
mapTo :: (Reducer e m, Monoid m) => (Elem c -> e) -> m -> c -> m
mapFrom :: (Reducer e m, Monoid m) => (Elem c -> e) -> c -> m -> m
mapReduce Elem c -> e
f = (Elem c -> e) -> m -> c -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> m -> c -> m
mapTo Elem c -> e
f m
forall a. Monoid a => a
mempty
mapTo Elem c -> e
f m
m = m -> m -> m
forall a. Monoid a => a -> a -> a
mappend m
m (m -> m) -> (c -> m) -> c -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Elem c -> e) -> c -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem c -> e
f
mapFrom Elem c -> e
f = m -> m -> m
forall a. Monoid a => a -> a -> a
mappend (m -> m -> m) -> (c -> m) -> c -> m -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Elem c -> e) -> c -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem c -> e
f
instance Generator Strict.ByteString where
type Elem Strict.ByteString = Word8
mapTo :: (Elem ByteString -> e) -> m -> ByteString -> m
mapTo Elem ByteString -> e
f = (m -> Word8 -> m) -> m -> ByteString -> m
forall a. (a -> Word8 -> a) -> a -> ByteString -> a
Strict.foldl' (\m
a -> m -> e -> m
forall c m. Reducer c m => m -> c -> m
snoc m
a (e -> m) -> (Word8 -> e) -> Word8 -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> e
Elem ByteString -> e
f)
instance Generator Lazy.ByteString where
type Elem Lazy.ByteString = Word8
mapReduce :: (Elem ByteString -> e) -> ByteString -> m
mapReduce Elem ByteString -> e
f = [m] -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold ([m] -> m) -> (ByteString -> [m]) -> ByteString -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> m) -> [ByteString] -> [m]
forall a b. (a -> b) -> [a] -> [b]
map ((Elem ByteString -> e) -> ByteString -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem ByteString -> e
Elem ByteString -> e
f) ([ByteString] -> [m])
-> (ByteString -> [ByteString]) -> ByteString -> [m]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
Lazy.toChunks
instance Generator Text where
type Elem Text = Char
mapTo :: (Elem Text -> e) -> m -> Text -> m
mapTo Elem Text -> e
f = (m -> Char -> m) -> m -> Text -> m
forall a. (a -> Char -> a) -> a -> Text -> a
Text.foldl' (\m
a -> m -> e -> m
forall c m. Reducer c m => m -> c -> m
snoc m
a (e -> m) -> (Char -> e) -> Char -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> e
Elem Text -> e
f)
instance Generator [c] where
type Elem [c] = c
mapReduce :: (Elem [c] -> e) -> [c] -> m
mapReduce Elem [c] -> e
f = (c -> m -> m) -> m -> [c] -> m
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (e -> m -> m
forall c m. Reducer c m => c -> m -> m
cons (e -> m -> m) -> (c -> e) -> c -> m -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> e
Elem [c] -> e
f) m
forall a. Monoid a => a
mempty
instance Generator (NonEmpty c) where
type Elem (NonEmpty c) = c
mapReduce :: (Elem (NonEmpty c) -> e) -> NonEmpty c -> m
mapReduce Elem (NonEmpty c) -> e
f = (Elem [c] -> e) -> [c] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [c] -> e
Elem (NonEmpty c) -> e
f ([c] -> m) -> (NonEmpty c -> [c]) -> NonEmpty c -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty c -> [c]
forall a. NonEmpty a -> [a]
NonEmpty.toList
instance Generator (FingerTree v e) where
type Elem (FingerTree v e) = e
mapReduce :: (Elem (FingerTree v e) -> e) -> FingerTree v e -> m
mapReduce Elem (FingerTree v e) -> e
f = (e -> m) -> FingerTree v e -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (e -> m
forall c m. Reducer c m => c -> m
unit (e -> m) -> (e -> e) -> e -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> e
Elem (FingerTree v e) -> e
f)
instance Generator (Seq c) where
type Elem (Seq c) = c
mapReduce :: (Elem (Seq c) -> e) -> Seq c -> m
mapReduce Elem (Seq c) -> e
f = (c -> m) -> Seq c -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (e -> m
forall c m. Reducer c m => c -> m
unit (e -> m) -> (c -> e) -> c -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> e
Elem (Seq c) -> e
f)
instance Generator IntSet where
type Elem IntSet = Int
mapReduce :: (Elem IntSet -> e) -> IntSet -> m
mapReduce Elem IntSet -> e
f = (Elem [Key] -> e) -> [Key] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [Key] -> e
Elem IntSet -> e
f ([Key] -> m) -> (IntSet -> [Key]) -> IntSet -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntSet -> [Key]
IntSet.toList
instance Generator (HashSet a) where
type Elem (HashSet a) = a
mapReduce :: (Elem (HashSet a) -> e) -> HashSet a -> m
mapReduce Elem (HashSet a) -> e
f = (Elem [a] -> e) -> [a] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [a] -> e
Elem (HashSet a) -> e
f ([a] -> m) -> (HashSet a -> [a]) -> HashSet a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashSet a -> [a]
forall a. HashSet a -> [a]
HashSet.toList
instance Generator (Set a) where
type Elem (Set a) = a
mapReduce :: (Elem (Set a) -> e) -> Set a -> m
mapReduce Elem (Set a) -> e
f = (Elem [a] -> e) -> [a] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [a] -> e
Elem (Set a) -> e
f ([a] -> m) -> (Set a -> [a]) -> Set a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
Set.toList
instance Generator (IntMap v) where
type Elem (IntMap v) = (Int,v)
mapReduce :: (Elem (IntMap v) -> e) -> IntMap v -> m
mapReduce Elem (IntMap v) -> e
f = (Elem [(Key, v)] -> e) -> [(Key, v)] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [(Key, v)] -> e
Elem (IntMap v) -> e
f ([(Key, v)] -> m) -> (IntMap v -> [(Key, v)]) -> IntMap v -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap v -> [(Key, v)]
forall a. IntMap a -> [(Key, a)]
IntMap.toList
instance Generator (Map k v) where
type Elem (Map k v) = (k,v)
mapReduce :: (Elem (Map k v) -> e) -> Map k v -> m
mapReduce Elem (Map k v) -> e
f = (Elem [(k, v)] -> e) -> [(k, v)] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [(k, v)] -> e
Elem (Map k v) -> e
f ([(k, v)] -> m) -> (Map k v -> [(k, v)]) -> Map k v -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toList
instance Generator (HashMap k v) where
type Elem (HashMap k v) = (k, v)
mapReduce :: (Elem (HashMap k v) -> e) -> HashMap k v -> m
mapReduce Elem (HashMap k v) -> e
f = (Elem [(k, v)] -> e) -> [(k, v)] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [(k, v)] -> e
Elem (HashMap k v) -> e
f ([(k, v)] -> m) -> (HashMap k v -> [(k, v)]) -> HashMap k v -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k v -> [(k, v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList
instance Ix i => Generator (Array i e) where
type Elem (Array i e) = (i,e)
mapReduce :: (Elem (Array i e) -> e) -> Array i e -> m
mapReduce Elem (Array i e) -> e
f = (Elem [(i, e)] -> e) -> [(i, e)] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [(i, e)] -> e
Elem (Array i e) -> e
f ([(i, e)] -> m) -> (Array i e -> [(i, e)]) -> Array i e -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [(i, e)]
forall i e. Ix i => Array i e -> [(i, e)]
assocs
newtype Keys c = Keys { Keys c -> c
getKeys :: c }
instance Generator (Keys (IntMap v)) where
type Elem (Keys (IntMap v)) = Int
mapReduce :: (Elem (Keys (IntMap v)) -> e) -> Keys (IntMap v) -> m
mapReduce Elem (Keys (IntMap v)) -> e
f = (Elem [Key] -> e) -> [Key] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [Key] -> e
Elem (Keys (IntMap v)) -> e
f ([Key] -> m) -> (Keys (IntMap v) -> [Key]) -> Keys (IntMap v) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap v -> [Key]
forall a. IntMap a -> [Key]
IntMap.keys (IntMap v -> [Key])
-> (Keys (IntMap v) -> IntMap v) -> Keys (IntMap v) -> [Key]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Keys (IntMap v) -> IntMap v
forall c. Keys c -> c
getKeys
instance Generator (Keys (Map k v)) where
type Elem (Keys (Map k v)) = k
mapReduce :: (Elem (Keys (Map k v)) -> e) -> Keys (Map k v) -> m
mapReduce Elem (Keys (Map k v)) -> e
f = (Elem [k] -> e) -> [k] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [k] -> e
Elem (Keys (Map k v)) -> e
f ([k] -> m) -> (Keys (Map k v) -> [k]) -> Keys (Map k v) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k v -> [k]
forall k a. Map k a -> [k]
Map.keys (Map k v -> [k])
-> (Keys (Map k v) -> Map k v) -> Keys (Map k v) -> [k]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Keys (Map k v) -> Map k v
forall c. Keys c -> c
getKeys
instance Ix i => Generator (Keys (Array i e)) where
type Elem (Keys (Array i e)) = i
mapReduce :: (Elem (Keys (Array i e)) -> e) -> Keys (Array i e) -> m
mapReduce Elem (Keys (Array i e)) -> e
f = (Elem [i] -> e) -> [i] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [i] -> e
Elem (Keys (Array i e)) -> e
f ([i] -> m) -> (Keys (Array i e) -> [i]) -> Keys (Array i e) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (i, i) -> [i]
forall a. Ix a => (a, a) -> [a]
range ((i, i) -> [i])
-> (Keys (Array i e) -> (i, i)) -> Keys (Array i e) -> [i]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> (i, i)
forall i e. Array i e -> (i, i)
bounds (Array i e -> (i, i))
-> (Keys (Array i e) -> Array i e) -> Keys (Array i e) -> (i, i)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Keys (Array i e) -> Array i e
forall c. Keys c -> c
getKeys
newtype Values c = Values { Values c -> c
getValues :: c }
instance Generator (Values (IntMap v)) where
type Elem (Values (IntMap v)) = v
mapReduce :: (Elem (Values (IntMap v)) -> e) -> Values (IntMap v) -> m
mapReduce Elem (Values (IntMap v)) -> e
f = (Elem [v] -> e) -> [v] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [v] -> e
Elem (Values (IntMap v)) -> e
f ([v] -> m) -> (Values (IntMap v) -> [v]) -> Values (IntMap v) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap v -> [v]
forall a. IntMap a -> [a]
IntMap.elems (IntMap v -> [v])
-> (Values (IntMap v) -> IntMap v) -> Values (IntMap v) -> [v]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Values (IntMap v) -> IntMap v
forall c. Values c -> c
getValues
instance Generator (Values (Map k v)) where
type Elem (Values (Map k v)) = v
mapReduce :: (Elem (Values (Map k v)) -> e) -> Values (Map k v) -> m
mapReduce Elem (Values (Map k v)) -> e
f = (Elem [v] -> e) -> [v] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [v] -> e
Elem (Values (Map k v)) -> e
f ([v] -> m) -> (Values (Map k v) -> [v]) -> Values (Map k v) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k v -> [v]
forall k a. Map k a -> [a]
Map.elems (Map k v -> [v])
-> (Values (Map k v) -> Map k v) -> Values (Map k v) -> [v]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Values (Map k v) -> Map k v
forall c. Values c -> c
getValues
#if MIN_VERSION_base(4,9,0)
instance Generator (Values (Array i e)) where
#else
instance Ix i => Generator (Values (Array i e)) where
#endif
type Elem (Values (Array i e)) = e
mapReduce :: (Elem (Values (Array i e)) -> e) -> Values (Array i e) -> m
mapReduce Elem (Values (Array i e)) -> e
f = (Elem [e] -> e) -> [e] -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem [e] -> e
Elem (Values (Array i e)) -> e
f ([e] -> m)
-> (Values (Array i e) -> [e]) -> Values (Array i e) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
forall i e. Array i e -> [e]
elems (Array i e -> [e])
-> (Values (Array i e) -> Array i e) -> Values (Array i e) -> [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Values (Array i e) -> Array i e
forall c. Values c -> c
getValues
newtype Char8 c = Char8 { Char8 c -> c
getChar8 :: c }
instance Generator (Char8 Strict.ByteString) where
type Elem (Char8 Strict.ByteString) = Char
mapTo :: (Elem (Char8 ByteString) -> e) -> m -> Char8 ByteString -> m
mapTo Elem (Char8 ByteString) -> e
f m
m = (m -> Char -> m) -> m -> ByteString -> m
forall a. (a -> Char -> a) -> a -> ByteString -> a
Strict8.foldl' (\m
a -> m -> e -> m
forall c m. Reducer c m => m -> c -> m
snoc m
a (e -> m) -> (Char -> e) -> Char -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> e
Elem (Char8 ByteString) -> e
f) m
m (ByteString -> m)
-> (Char8 ByteString -> ByteString) -> Char8 ByteString -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char8 ByteString -> ByteString
forall c. Char8 c -> c
getChar8
instance Generator (Char8 Lazy.ByteString) where
type Elem (Char8 Lazy.ByteString) = Char
mapReduce :: (Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m
mapReduce Elem (Char8 ByteString) -> e
f = [m] -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold ([m] -> m) -> (Char8 ByteString -> [m]) -> Char8 ByteString -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> m) -> [ByteString] -> [m]
forall a b. (a -> b) -> [a] -> [b]
map ((Elem (Char8 ByteString) -> e) -> Char8 ByteString -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem (Char8 ByteString) -> e
Elem (Char8 ByteString) -> e
f (Char8 ByteString -> m)
-> (ByteString -> Char8 ByteString) -> ByteString -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Char8 ByteString
forall c. c -> Char8 c
Char8) ([ByteString] -> [m])
-> (Char8 ByteString -> [ByteString]) -> Char8 ByteString -> [m]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
Lazy8.toChunks (ByteString -> [ByteString])
-> (Char8 ByteString -> ByteString)
-> Char8 ByteString
-> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char8 ByteString -> ByteString
forall c. Char8 c -> c
getChar8
reduce :: (Generator c, Reducer (Elem c) m, Monoid m) => c -> m
reduce :: c -> m
reduce = (Elem c -> Elem c) -> c -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem c -> Elem c
forall a. a -> a
id
{-# SPECIALIZE reduce :: (Reducer Word8 m, Monoid m) => Strict.ByteString -> m #-}
{-# SPECIALIZE reduce :: (Reducer Word8 m, Monoid m) => Lazy.ByteString -> m #-}
{-# SPECIALIZE reduce :: (Reducer Char m, Monoid m) => Char8 Strict.ByteString -> m #-}
{-# SPECIALIZE reduce :: (Reducer Char m, Monoid m) => Char8 Lazy.ByteString -> m #-}
{-# SPECIALIZE reduce :: (Reducer c m, Monoid m) => [c] -> m #-}
{-# SPECIALIZE reduce :: (Reducer e m, Monoid m) => FingerTree v e -> m #-}
{-# SPECIALIZE reduce :: (Reducer Char m, Monoid m) => Text -> m #-}
{-# SPECIALIZE reduce :: (Reducer e m, Monoid m) => Seq e -> m #-}
{-# SPECIALIZE reduce :: (Reducer Int m, Monoid m) => IntSet -> m #-}
{-# SPECIALIZE reduce :: (Reducer a m, Monoid m) => Set a -> m #-}
{-# SPECIALIZE reduce :: (Reducer a m, Monoid m) => HashSet a -> m #-}
{-# SPECIALIZE reduce :: (Reducer (Int,v) m, Monoid m) => IntMap v -> m #-}
{-# SPECIALIZE reduce :: (Reducer (k,v) m, Monoid m) => Map k v -> m #-}
{-# SPECIALIZE reduce :: (Reducer (k,v) m, Monoid m) => HashMap k v -> m #-}
{-# SPECIALIZE reduce :: (Reducer Int m, Monoid m) => Keys (IntMap v) -> m #-}
{-# SPECIALIZE reduce :: (Reducer k m, Monoid m) => Keys (Map k v) -> m #-}
{-# SPECIALIZE reduce :: (Reducer v m, Monoid m) => Values (IntMap v) -> m #-}
{-# SPECIALIZE reduce :: (Reducer v m, Monoid m) => Values (Map k v) -> m #-}
mapReduceWith :: (Generator c, Reducer e m, Monoid m) => (m -> n) -> (Elem c -> e) -> c -> n
mapReduceWith :: (m -> n) -> (Elem c -> e) -> c -> n
mapReduceWith m -> n
f Elem c -> e
g = m -> n
f (m -> n) -> (c -> m) -> c -> n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Elem c -> e) -> c -> m
forall c e m.
(Generator c, Reducer e m, Monoid m) =>
(Elem c -> e) -> c -> m
mapReduce Elem c -> e
g
{-# INLINE mapReduceWith #-}
reduceWith :: (Generator c, Reducer (Elem c) m, Monoid m) => (m -> n) -> c -> n
reduceWith :: (m -> n) -> c -> n
reduceWith m -> n
f = m -> n
f (m -> n) -> (c -> m) -> c -> n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m
forall c m. (Generator c, Reducer (Elem c) m, Monoid m) => c -> m
reduce
{-# INLINE reduceWith #-}