-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Semigroups, specialized containers and a general map/reduce framework
--   
--   Semigroups, specialized containers and a general map/reduce framework
@package reducers
@version 3.10.1.1

module Data.Semigroup.Instances
instance Measured v a => Semigroup (FingerTree v a)

-- | A c-Reducer is a Semigroup with a canonical
--   mapping from c to the Semigroup.
module Data.Semigroup.Reducer

-- | This type may be best read infix. A c Reducer m is a
--   Semigroup m that maps values of type c
--   through unit to values of type m. A
--   c-Reducer may also supply operations which tack-on
--   another c to an existing Monoid m on the left
--   or right. These specialized reductions may be more efficient in some
--   scenarios and are used when appropriate by a Generator. The
--   names cons and snoc work by analogy to the synonymous
--   operations in the list monoid.
--   
--   This class deliberately avoids functional-dependencies, so that () can
--   be a c-Reducer for all c, and so many common
--   reducers can work over multiple types, for instance, First and Last
--   may reduce both a and Maybe a. Since a
--   Generator has a fixed element type, the input to the reducer
--   is generally known and extracting from the monoid usually is
--   sufficient to fix the result type. Combinators are available for most
--   scenarios where this is not the case, and the few remaining cases can
--   be handled by using an explicit type annotation.
--   
--   Minimal definition: unit
class Semigroup m => Reducer c m where snoc m = (<>) m . unit cons = (<>) . unit
unit :: Reducer c m => c -> m
snoc :: Reducer c m => m -> c -> m
cons :: Reducer c m => c -> m -> m

-- | Apply a Reducer to a Foldable container, after mapping
--   the contents into a suitable form for reduction.
foldMapReduce :: (Foldable f, Monoid m, Reducer e m) => (a -> e) -> f a -> m
foldMapReduce1 :: (Foldable1 f, Reducer e m) => (a -> e) -> f a -> m

-- | Apply a Reducer to a Foldable mapping each element
--   through unit
foldReduce :: (Foldable f, Monoid m, Reducer e m) => f e -> m

-- | Apply a Reducer to a Foldable1 mapping each element
--   through unit
foldReduce1 :: (Foldable1 f, Reducer e m) => f e -> m
pureUnit :: (Applicative f, Reducer c n) => c -> f n
returnUnit :: (Monad m, Reducer c n) => c -> m n
newtype Count
Count :: Int -> Count
getCount :: Count -> Int
instance Typeable Count
instance Eq Count
instance Ord Count
instance Show Count
instance Read Count
instance Data Count
instance Monoid m => Reducer m (WrappedMonoid m)
instance Ord k => Reducer (k, v) (Map k v)
instance Reducer (Int, v) (IntMap v)
instance Ord a => Reducer a (Set a)
instance Reducer Int IntSet
instance Reducer a (Seq a)
instance Measured v a => Reducer a (FingerTree v a)
instance Reducer a (Last a)
instance Reducer (Maybe a) (Last a)
instance Reducer a (First a)
instance Reducer (Maybe a) (First a)
instance Ord a => Reducer a (Max a)
instance Ord a => Reducer a (Min a)
instance Num a => Reducer a (Product a)
instance Num a => Reducer a (Sum a)
instance Semigroup a => Reducer a (Dual a)
instance Reducer (a -> a) (Endo a)
instance Reducer Bool All
instance Reducer Bool Any
instance Reducer c ()
instance Reducer c [c]
instance (Reducer c m, Reducer c n, Reducer c o, Reducer c p) => Reducer c (m, n, o, p)
instance (Reducer c m, Reducer c n, Reducer c o) => Reducer c (m, n, o)
instance (Reducer c m, Reducer c n) => Reducer c (m, n)
instance Reducer a Count
instance Monoid Count
instance Semigroup Count
instance Hashable Count

-- | Semigroups for working with Applicative Functors.
module Data.Semigroup.Applicative

-- | A Traversal uses an glues together Applicative actions
--   with (*>) in the manner of traverse_ from
--   Data.Foldable. Any values returned by reduced actions are
--   discarded.
newtype Traversal f
Traversal :: f () -> Traversal f
getTraversal :: Traversal f -> f ()
newtype Ap f m
Ap :: f m -> Ap f m
getApp :: Ap f m -> f m
instance Functor f => Functor (Ap f)
instance Applicative f => Applicative (Ap f)
instance (Applicative f, Reducer c m) => Reducer (f c) (Ap f m)
instance (Applicative f, Monoid m) => Monoid (Ap f m)
instance (Applicative f, Semigroup m) => Semigroup (Ap f m)
instance Applicative f => Reducer (f a) (Traversal f)
instance Applicative f => Monoid (Traversal f)
instance Applicative f => Semigroup (Traversal f)

-- | A semigroup for working with Alternative Functors.
module Data.Semigroup.Alternative

-- | A Alternate turns any Alternative instance into a
--   Monoid.
newtype Alternate f a
Alternate :: f a -> Alternate f a
getAlternate :: Alternate f a -> f a
instance Functor f => Functor (Alternate f)
instance Applicative f => Applicative (Alternate f)
instance Alternative f => Alternative (Alternate f)
instance Alternative f => Reducer (f a) (Alternate f a)
instance Alternative f => Monoid (Alternate f a)
instance Alternative f => Semigroup (Alternate f a)

-- | Semigroups for working with Monads.
module Data.Semigroup.Monad

-- | A Action uses an glues together monadic actions with (>>)
--   in the manner of mapM_ from Data.Foldable. Any values
--   returned by reduced actions are discarded.
newtype Action f
Action :: f () -> Action f
getAction :: Action f -> f ()
newtype Mon f m
Mon :: f m -> Mon f m
getMon :: Mon f m -> f m
instance Monad f => Monad (Mon f)
instance (Monad f, Reducer c m) => Reducer (f c) (Mon f m)
instance (Monad f, Monoid m) => Monoid (Mon f m)
instance (Monad f, Semigroup m) => Semigroup (Mon f m)
instance Monad f => Reducer (f a) (Action f)
instance Monad f => Monoid (Action f)
instance Monad f => Semigroup (Action f)

-- | A semigroup for working with instances of MonadPlus
module Data.Semigroup.MonadPlus

-- | A MonadSum turns any MonadPlus instance into a
--   Monoid.
newtype MonadSum f a
MonadSum :: f a -> MonadSum f a
getMonadSum :: MonadSum f a -> f a
instance Monad f => Monad (MonadSum f)
instance MonadPlus f => MonadPlus (MonadSum f)
instance MonadPlus f => Reducer (f a) (MonadSum f a)
instance MonadPlus f => Monoid (MonadSum f a)
instance MonadPlus f => Semigroup (MonadSum f a)

module Data.Semigroup.Reducer.With

-- | If m is a c-Reducer, then m is (c
--   WithReducer m)-Reducer This can be used to quickly
--   select a Reducer for use as a FingerTree measure.
newtype WithReducer m c
WithReducer :: c -> WithReducer m c
withoutReducer :: WithReducer m c -> c
instance Eq c => Eq (WithReducer m c)
instance Ord c => Ord (WithReducer m c)
instance Show c => Show (WithReducer m c)
instance Read c => Read (WithReducer m c)
instance (Monoid m, Reducer c m) => Measured m (WithReducer m c)
instance Reducer c m => Reducer (WithReducer m c) m
instance Traversable1 (WithReducer m)
instance Foldable1 (WithReducer m)
instance Traversable (WithReducer m)
instance Foldable (WithReducer m)
instance Functor (WithReducer m)
instance Hashable c => Hashable (WithReducer m c)

module Data.Semigroup.Union

-- | A Container suitable for the Union Monoid
class HasUnion f
union :: HasUnion f => f -> f -> f
class HasUnion f => HasUnion0 f
empty :: HasUnion0 f => f

-- | The Monoid (union,empty)
newtype Union f
Union :: f -> Union f
getUnion :: Union f -> f

-- | Polymorphic containers that we can supply an operation to handle
--   unions with
class Functor f => HasUnionWith f
unionWith :: HasUnionWith f => (a -> a -> a) -> f a -> f a -> f a
class HasUnionWith f => HasUnionWith0 f
emptyWith :: HasUnionWith0 f => f a

-- | The Monoid ('unionWith mappend',empty) for
--   containers full of monoids.
newtype UnionWith f m
UnionWith :: f m -> UnionWith f m
getUnionWith :: UnionWith f m -> f m
instance Eq f => Eq (Union f)
instance Ord f => Ord (Union f)
instance Show f => Show (Union f)
instance Read f => Read (Union f)
instance (HasUnionWith f, Semigroup m, Monoid m) => Reducer (f m) (UnionWith f m)
instance (HasUnionWith0 f, Monoid m) => Monoid (UnionWith f m)
instance (HasUnionWith f, Semigroup m) => Semigroup (UnionWith f m)
instance Ord k => HasUnionWith0 (Map k)
instance Ord k => HasUnionWith (Map k)
instance HasUnionWith0 IntMap
instance HasUnionWith IntMap
instance Traversable1 Union
instance Foldable1 Union
instance Traversable Union
instance Foldable Union
instance Functor Union
instance HasUnion f => Reducer f (Union f)
instance HasUnion0 f => Monoid (Union f)
instance HasUnion f => Semigroup (Union f)
instance (Eq a, Hashable a) => HasUnion0 (HashSet a)
instance (Eq a, Hashable a) => HasUnion (HashSet a)
instance HasUnion0 IntSet
instance HasUnion IntSet
instance Ord a => HasUnion0 (Set a)
instance Ord a => HasUnion (Set a)
instance Eq a => HasUnion0 [a]
instance Eq a => HasUnion [a]
instance Ord k => HasUnion0 (Map k a)
instance Ord k => HasUnion (Map k a)
instance (Eq k, Hashable k) => HasUnion0 (HashMap k a)
instance (Eq k, Hashable k) => HasUnion (HashMap k a)
instance HasUnion0 (IntMap a)
instance HasUnion (IntMap a)

-- | Semigroups for working with Apply
module Data.Semigroup.Apply

-- | A Trav uses an glues together Applicative actions with
--   (*>) in the manner of traverse_ from Data.Foldable.
--   Any values returned by reduced actions are discarded.
newtype Trav f
Trav :: f () -> Trav f
getTrav :: Trav f -> f ()

-- | A App turns any Apply wrapped around a Semigroup
--   into a Semigroup
newtype App f m
App :: f m -> App f m
getApp :: App f m -> f m
instance Functor f => Functor (App f)
instance Apply f => Apply (App f)
instance (Apply f, Reducer c m) => Reducer (f c) (App f m)
instance (Apply f, Semigroup m) => Semigroup (App f m)
instance Apply f => Reducer (f a) (Trav f)
instance Apply f => Semigroup (Trav f)

-- | A semigroup for working Alt or Plus
module Data.Semigroup.Alt

-- | A Alter turns any Alt instance into a Semigroup.
newtype Alter f a
Alter :: f a -> Alter f a
getAlter :: Alter f a -> f a
instance Functor f => Functor (Alter f)
instance Alt f => Alt (Alter f)
instance Plus f => Plus (Alter f)
instance Alt f => Reducer (f a) (Alter f a)
instance Plus f => Monoid (Alter f a)
instance Alt f => Semigroup (Alter f a)

-- | A simple Monoid transformer that takes a Monoid m and
--   produces a new m-Reducer named Self m
--   
--   This is useful when you have a generator that already contains
--   monoidal values or someone supplies the map to the monoid in the form
--   of a function rather than as a Reducer instance. You can just
--   getSelf . reduce or getSelf .
--   mapReduce f in those scenarios. These behaviors are
--   encapsulated into the fold and foldMap combinators in
--   Data.Monoid.Combinators respectively.
module Data.Semigroup.Self
newtype Self m
Self :: m -> Self m
getSelf :: Self m -> m
instance Semigroup m => Semigroup (Self m)
instance Monoid m => Monoid (Self m)
instance Traversable1 Self
instance Foldable1 Self
instance Traversable Self
instance Foldable Self
instance Functor Self
instance Semigroup m => Reducer m (Self m)

-- | 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.
module Data.Generator

-- | minimal definition mapReduce or mapTo
class Generator c where type family Elem c mapReduce f = mapTo f mempty mapTo f m = mappend m . mapReduce f mapFrom f = mappend . mapReduce f
mapReduce :: (Generator c, Reducer e m, Monoid m) => (Elem c -> e) -> c -> m
mapTo :: (Generator c, Reducer e m, Monoid m) => (Elem c -> e) -> m -> c -> m
mapFrom :: (Generator c, Reducer e m, Monoid m) => (Elem c -> e) -> c -> m -> m

-- | a Generator transformer that asks only for the keys of an
--   indexed container
newtype Keys c
Keys :: c -> Keys c
getKeys :: Keys c -> c

-- | a Generator transformer that asks only for the values contained
--   in an indexed container
newtype Values c
Values :: c -> Values c
getValues :: Values c -> c

-- | 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
newtype Char8 c
Char8 :: c -> Char8 c
getChar8 :: Char8 c -> c

-- | Apply a Reducer directly to the elements of a Generator
reduce :: (Generator c, Reducer (Elem c) m, Monoid m) => c -> m
mapReduceWith :: (Generator c, Reducer e m, Monoid m) => (m -> n) -> (Elem c -> e) -> c -> n
reduceWith :: (Generator c, Reducer (Elem c) m, Monoid m) => (m -> n) -> c -> n
instance Generator (Char8 ByteString)
instance Generator (Char8 ByteString)
instance Ix i => Generator (Values (Array i e))
instance Generator (Values (Map k v))
instance Generator (Values (IntMap v))
instance Ix i => Generator (Keys (Array i e))
instance Generator (Keys (Map k v))
instance Generator (Keys (IntMap v))
instance Ix i => Generator (Array i e)
instance Generator (HashMap k v)
instance Generator (Map k v)
instance Generator (IntMap v)
instance Generator (Set a)
instance Generator (HashSet a)
instance Generator IntSet
instance Generator (Seq c)
instance Measured v e => Generator (FingerTree v e)
instance Generator (NonEmpty c)
instance Generator [c]
instance Generator Text
instance Generator ByteString
instance Generator ByteString

-- | 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
--   
module Data.Generator.Combinators

-- | Efficiently mapReduce a Generator using the
--   Action monoid. A specialized version of its namesake from
--   Data.Foldable and Control.Monad
--   
--   
--   mapReduceWith getAction
--   
mapM_ :: (Generator c, Monad m) => (Elem c -> m b) -> c -> m ()

-- | Convenience function as found in Data.Foldable and
--   Control.Monad
--   
--   
--   flip mapM_
--   
forM_ :: (Generator c, Monad m) => c -> (Elem c -> m b) -> m ()

-- | The sum of a collection of actions, generalizing concat
--   
--   
--   reduceWith getMonadSum
--   
msum :: (Generator c, MonadPlus m, m a ~ Elem c) => c -> m a

-- | Efficiently mapReduce a Generator using the
--   Traversal monoid. A specialized version of its namesake from
--   Data.Foldable
--   
--   
--   mapReduce getTraversal
--   
traverse_ :: (Generator c, Applicative f) => (Elem c -> f b) -> c -> f ()

-- | Convenience function as found in Data.Foldable
--   
--   
--   flip traverse_
--   
for_ :: (Generator c, Applicative f) => c -> (Elem c -> f b) -> f ()

-- | The sum of a collection of actions, generalizing concat
--   
--   
--   reduceWith getAlt
--   
asum :: (Generator c, Alternative f, f a ~ Elem c) => c -> f a

-- | Efficiently reduce a Generator that contains values of
--   type Bool
--   
--   
--   reduceWith getAll
--   
and :: (Generator c, Elem c ~ Bool) => c -> Bool

-- | Efficiently reduce a Generator that contains values of
--   type Bool
--   
--   
--   reduceWith getAny
--   
or :: (Generator c, Elem c ~ Bool) => c -> Bool

-- | Efficiently mapReduce any Generator checking to see if
--   any of its values match the supplied predicate
--   
--   
--   mapReduceWith getAny
--   
any :: Generator c => (Elem c -> Bool) -> c -> Bool

-- | Efficiently mapReduce any Generator checking to see if
--   all of its values match the supplied predicate
--   
--   
--   mapReduceWith getAll
--   
all :: Generator c => (Elem c -> Bool) -> c -> Bool

-- | Efficiently mapReduce a Generator using the
--   WrappedMonoid monoid. A specialized version of its namesake
--   from Data.Foldable
--   
--   
--   mapReduceWith unwrapMonoid
--   
foldMap :: (Monoid m, Generator c) => (Elem c -> m) -> c -> m

-- | Efficiently reduce a Generator using the
--   WrappedMonoid monoid. A specialized version of its namesake
--   from Data.Foldable
--   
--   
--   reduceWith unwrapMonoid
--   
fold :: (Monoid m, Generator c, Elem c ~ m) => c -> m

-- | Convert any Generator to a list of its contents. Specialization
--   of reduce
toList :: Generator c => c -> [Elem c]

-- | Type specialization of foldMap above
concatMap :: Generator c => (Elem c -> [b]) -> c -> [b]

-- | Check to see if any member of the Generator matches the
--   supplied value
elem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool

-- | Efficiently mapReduce a subset of the elements in a
--   Generator
filter :: (Generator c, Reducer (Elem c) m, Monoid m) => (Elem c -> Bool) -> c -> m

-- | Allows idiomatic specialization of filter by proving a function that
--   will be used to transform the output
filterWith :: (Generator c, Reducer (Elem c) m, Monoid m) => (m -> n) -> (Elem c -> Bool) -> c -> n

-- | Efficiently sum over the members of any Generator
--   
--   
--   reduceWith getSum
--   
sum :: (Generator c, Num (Elem c)) => c -> Elem c

-- | Efficiently take the product of every member of a Generator
--   
--   
--   reduceWith getProduct
--   
product :: (Generator c, Num (Elem c)) => c -> Elem c

-- | Check to make sure that the supplied value is not a member of the
--   Generator
notElem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool

-- | 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.
module Data.Semigroup.Generator

-- | minimal definition mapReduce1 or mapTo1
class Generator c => Generator1 c where mapTo1 f m = (<>) m . mapReduce1 f mapFrom1 f = (<>) . mapReduce1 f
mapReduce1 :: (Generator1 c, Reducer e m) => (Elem c -> e) -> c -> m
mapTo1 :: (Generator1 c, Reducer e m) => (Elem c -> e) -> m -> c -> m
mapFrom1 :: (Generator1 c, Reducer e m) => (Elem c -> e) -> c -> m -> m

-- | Apply a Reducer directly to the elements of a Generator
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
instance Generator1 (NonEmpty e)
