-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Monoids, specialized containers and a general map/reduce framework -- -- Monoids, specialized containers and a general map/reduce framework @package monoids @version 0.1.21 -- | A collection of orphan instance declarations for Monoids that should -- eventually be pushed back down to the source packages. -- -- Every package that uses these instances includes this package -- internally. -- -- Includes: -- --
-- import Data.Monoid.Additive --module Data.Monoid.Additive plus :: (Monoid m) => m -> m -> m zero :: (Monoid m) => m -- | Syntactic sugar for working with a Monoid that conflicts with -- names from the Prelude. -- --
-- import Prelude hiding ((+)) -- import Data.Monoid.Additive.Sugar --module Data.Monoid.Additive.Sugar (+) :: (Monoid m) => m -> m -> m -- | When dealing with a Ring or other structure, you often need a pair of -- Monoid instances that are closely related. Making a -- newtype for one is unsatisfying and yields an unnatural -- programming style. -- -- A Multiplicative is a Monoid that is intended for use in -- a scenario that can be extended to have another Monoid slot in -- for addition. This enables one to use common notation. -- -- Any Multiplicative can be turned into a Monoid using the -- Log wrapper. -- -- Any Monoid can be turned into a Multiplicative using the -- Exp wrapper. -- -- Instances are supplied for common Monads of Monoids, in a fashion -- which can be extended if the Monad is a MonadPlus to -- yield a LeftSemiNearRing -- -- Instances are also supplied for common Applicatives of Monoids, in a -- fashion which can be extended if the Applicative is -- Alternative to yield a LeftSemiNearRing module Data.Monoid.Multiplicative class Multiplicative m one :: (Multiplicative m) => m times :: (Multiplicative m) => m -> m -> m -- | Convert a Multiplicative into a Monoid. Mnemonic: -- Log a + Log b = Log (a * b) data Log m Log :: m -> Log m getLog :: Log m -> m -- | Convert a Monoid into a Multiplicative. Mnemonic: -- Exp a * Exp b = Exp (a + b) data Exp m Exp :: m -> Exp m getExp :: Exp m -> m instance (Integral m) => Multiplicative (Ratio m) instance Multiplicative Integer instance Multiplicative Int instance (Monoid m) => Multiplicative (Const m a) instance (Monoid n) => Multiplicative (ZipList n) instance (Stream s m t, Monoid n) => Multiplicative (ParsecT s u m n) instance (Monoid n) => Multiplicative (STM n) instance (Monoid n) => Multiplicative (ST s n) instance (Monoid n) => Multiplicative (ST s n) instance (Monoid n) => Multiplicative (IO n) instance (Monad m, Monoid w, Monoid n) => Multiplicative (WriterT w m n) instance (Monad m, Monoid w, Monoid n) => Multiplicative (WriterT w m n) instance (Monad m, Monoid n) => Multiplicative (ReaderT e m n) instance (Monad m, Monoid n) => Multiplicative (StateT s m n) instance (Monad m, Monoid n) => Multiplicative (StateT s m n) instance (Monad m, Monoid w, Monoid n) => Multiplicative (RWST r w s m n) instance (Monad m, Monoid w, Monoid n) => Multiplicative (RWST r w s m n) instance (Monad m, Monoid n) => Multiplicative (ContT r m n) instance (Monoid w, Monoid m) => Multiplicative (Writer w m) instance (Monoid w, Monoid m) => Multiplicative (Writer w m) instance (Monoid m) => Multiplicative (Reader e m) instance (Monoid m) => Multiplicative (State s m) instance (Monoid m) => Multiplicative (State s m) instance (Monoid w, Monoid m) => Multiplicative (RWS r w s m) instance (Monoid w, Monoid m) => Multiplicative (RWS r w s m) instance (Monoid m) => Multiplicative (Cont r m) instance (Monoid m) => Multiplicative (Identity m) instance (Monoid m) => Multiplicative (Maybe m) instance (Measured v m, Monoid m) => Multiplicative (FingerTree v m) instance (Monoid m) => Multiplicative (Seq m) instance (Monoid m) => Multiplicative [m] instance (Multiplicative m) => Multiplicative (FromString m) instance (Multiplicative m) => Multiplicative (Self m) instance (Monoid m) => Multiplicative (Exp m) instance (Multiplicative m) => Monoid (Log m) -- | Syntactic sugar for working with a Multiplicative monoids that -- conflicts with names from the Prelude. -- --
-- import Prelude hiding ((+),(*)) -- import Data.Monoid.Multiplicative.Sugar --module Data.Monoid.Multiplicative.Sugar (*) :: (Multiplicative r) => r -> r -> r -- | Defines left- and right- seminearrings. Every MonadPlus wrapped -- around a Monoid qualifies due to the distributivity of -- (>>=) over mplus. -- -- See -- http://conway.rutgers.edu/~ccshan/wiki/blog/posts/WordNumbers1/ module Data.Ring.Semi.Near -- |
-- a * (b + c) = (a * b) + (a * c) --class (Multiplicative m, Monoid m) => LeftSemiNearRing m -- |
-- (a + b) * c = (a * c) + (b * c) --class (Multiplicative m, Monoid m) => RightSemiNearRing m instance (MonadPlus m, Monoid w, Monoid n) => LeftSemiNearRing (WriterT w m n) instance (MonadPlus m, Monoid w, Monoid n) => LeftSemiNearRing (WriterT w m n) instance (MonadPlus m, Monoid w, Monoid n) => LeftSemiNearRing (RWST r w s m n) instance (MonadPlus m, Monoid w, Monoid n) => LeftSemiNearRing (RWST r w s m n) instance (MonadPlus m, Monoid n) => LeftSemiNearRing (ReaderT e m n) instance (MonadPlus m, Monoid n) => LeftSemiNearRing (StateT s m n) instance (MonadPlus m, Monoid n) => LeftSemiNearRing (StateT s m n) instance (Stream s m t, Monoid a) => LeftSemiNearRing (ParsecT s u m a) instance (Monoid m) => LeftSemiNearRing (Seq m) instance (Monoid m) => LeftSemiNearRing (Maybe m) instance (Monoid m) => LeftSemiNearRing [m] instance (Measured v m, Monoid m) => LeftSemiNearRing (FingerTree v m) instance (LeftSemiNearRing m) => LeftSemiNearRing (FromString m) instance (LeftSemiNearRing m) => LeftSemiNearRing (Self m) instance (RightSemiNearRing m) => RightSemiNearRing (FromString m) instance (RightSemiNearRing m) => RightSemiNearRing (Self m) module Data.Ring.Semi -- | A SemiRing is an instance of both Multiplicative and -- Monoid where times distributes over plus. class (RightSemiNearRing a, LeftSemiNearRing a) => SemiRing a module Data.Monoid.Ord -- | The Monoid (max,minBound) newtype Max a Max :: a -> Max a getMax :: Max a -> a -- | The Monoid given by (min,maxBound) newtype Min a Min :: a -> Min a getMin :: Min a -> a -- | The Monoid (max,Nothing) over -- Maybe a where Nothing is the bottom element newtype MaxPriority a MaxPriority :: Maybe a -> MaxPriority a getMaxPriority :: MaxPriority a -> Maybe a minfinity :: MaxPriority a -- | The Monoid (min,Nothing) over -- Maybe a where Nothing is the top element newtype MinPriority a MinPriority :: Maybe a -> MinPriority a getMinPriority :: MinPriority a -> Maybe a infinity :: MinPriority a instance (Eq a) => Eq (MinPriority a) instance (Show a) => Show (MinPriority a) instance (Read a) => Read (MinPriority a) instance (Eq a) => Eq (MaxPriority a) instance (Ord a) => Ord (MaxPriority a) instance (Show a) => Show (MaxPriority a) instance (Read a) => Read (MaxPriority a) instance (Eq a) => Eq (Min a) instance (Ord a) => Ord (Min a) instance (Show a) => Show (Min a) instance (Read a) => Read (Min a) instance (Bounded a) => Bounded (Min a) instance (Eq a) => Eq (Max a) instance (Ord a) => Ord (Max a) instance (Show a) => Show (Max a) instance (Read a) => Read (Max a) instance (Bounded a) => Bounded (Max a) instance Pointed MinPriority instance Functor MinPriority instance (Ord a) => Reducer (Maybe a) (MinPriority a) instance (Ord a) => Monoid (MinPriority a) instance (Ord a) => Ord (MinPriority a) instance Pointed MaxPriority instance Functor MaxPriority instance (Ord a) => Reducer (Maybe a) (MaxPriority a) instance (Ord a) => Monoid (MaxPriority a) instance Copointed Min instance Pointed Min instance Functor Min instance (Ord a, Bounded a) => Reducer a (Min a) instance (Ord a, Bounded a) => Monoid (Min a) instance Copointed Max instance Pointed Max instance Functor Max instance (Ord a, Bounded a) => Reducer a (Max a) instance (Ord a, Bounded a) => Monoid (Max a) -- | Turn an instance of Ord into a SemiRing over max -- and min module Data.Ring.Semi.Ord -- | A SemiRing using a type's built-in Bounded instance. newtype Order a Order :: a -> Order a getOrder :: Order a -> a -- | A SemiRing which adds minBound and maxBound to a -- pre-existing type. data Priority a MinBound :: Priority a Priority :: a -> Priority a MaxBound :: Priority a instance (Eq a) => Eq (Priority a) instance (Read a) => Read (Priority a) instance (Show a) => Show (Priority a) instance (Eq a) => Eq (Order a) instance (Ord a) => Ord (Order a) instance (Read a) => Read (Order a) instance (Show a) => Show (Order a) instance (Bounded a) => Bounded (Order a) instance (Arbitrary a) => Arbitrary (Order a) instance (CoArbitrary a) => CoArbitrary (Order a) instance Pointed Priority instance Functor Priority instance (Ord a) => Reducer (MaxPriority a) (Priority a) instance (Ord a) => Reducer (MinPriority a) (Priority a) instance (Ord a) => Reducer a (Priority a) instance (Ord a) => SemiRing (Priority a) instance (Ord a) => RightSemiNearRing (Priority a) instance (Ord a) => LeftSemiNearRing (Priority a) instance (Ord a) => Multiplicative (Priority a) instance (Ord a) => Monoid (Priority a) instance (CoArbitrary a) => CoArbitrary (Priority a) instance (Arbitrary a) => Arbitrary (Priority a) instance (Ord a) => Ord (Priority a) instance Bounded (Priority a) instance Copointed Order instance Pointed Order instance Functor Order instance (Bounded a, Ord a) => Reducer a (Order a) instance (Bounded a, Ord a) => SemiRing (Order a) instance (Bounded a, Ord a) => LeftSemiNearRing (Order a) instance (Bounded a, Ord a) => RightSemiNearRing (Order a) instance (Bounded a, Ord a) => Multiplicative (Order a) instance (Bounded a, Ord a) => Monoid (Order a) module Data.Ring.Semi.Tropical infinity :: Tropical a -- | The SemiRing (min,+) over a extended -- with infinity. When a has a Num instance with an -- addition that respects order, then this is transformed into a tropical -- semiring. It is assumed that 0 is the least element of a. -- -- -- http://hal.archives-ouvertes.fr/docs/00/11/37/79/PDF/Tropical.pdf newtype Tropical a Tropical :: Maybe a -> Tropical a getTropical :: Tropical a -> Maybe a instance (Eq a) => Eq (Tropical a) instance (Show a) => Show (Tropical a) instance (Read a) => Read (Tropical a) instance (Arbitrary a) => Arbitrary (Tropical a) instance (CoArbitrary a) => CoArbitrary (Tropical a) instance (Ord a, Num a) => SemiRing (Tropical a) instance (Ord a, Num a) => RightSemiNearRing (Tropical a) instance (Ord a, Num a) => LeftSemiNearRing (Tropical a) instance (Num a) => Multiplicative (Tropical a) instance Pointed Tropical instance Functor Tropical instance (Ord a) => Reducer (MinPriority a) (Tropical a) instance (Ord a) => Reducer (Maybe a) (Tropical a) instance (Ord a) => Reducer a (Tropical a) instance (Ord a) => Monoid (Tropical a) instance (Ord a) => Ord (Tropical a) -- | Syntactic sugar for working with rings that conflicts with names from -- the Prelude. -- --
-- import Prelude hiding ((-), (+), (*), negate, subtract) -- import Data.Ring.Sugar --module Data.Ring.Sugar -- | Extends Monoid to support Group operations module Data.Group -- | Minimal complete definition: gnegate or minus class (Monoid a) => Group a gnegate :: (Group a) => a -> a minus :: (Group a) => a -> a -> a gsubtract :: (Group a) => a -> a -> a instance (Group a) => Group (FromString a) instance (Group a) => Group (Self a) instance (Group a) => Group (Dual a) instance (Fractional a) => Group (Product a) instance (Num a) => Group (Sum a) -- | Utilities for working with Groups that conflict with names from the -- Prelude. -- -- Intended to be imported qualified. -- --
-- import Data.Group.Combinators as Group (replicate) --module Data.Group.Combinators replicate :: (Group m, Integral n) => m -> n -> m prop_replicate_right_distributive :: (Eq g, Group g, Arbitrary g, Integral n) => g -> n -> n -> Bool -- | Syntactic sugar for working with groups that conflicts with names from -- the Prelude. -- --
-- import Prelude hiding ((-), (+), negate, subtract) -- import Data.Group.Sugar --module Data.Group.Sugar (-) :: (Group g) => g -> g -> g negate :: (Group g) => g -> g subtract :: (Group g) => g -> g -> g module Data.Ring class (Group a, SemiRing a) => Ring a -- | A Boolean Ring over Bool. Note well that the -- mappend of this ring is symmetric difference and not -- disjunction like you might expect. To get that you should use use -- Ord from Data.Ring.Semi.Ord.Order on Bool to get -- the '&&'/'||'-based distributive-lattice SemiRing module Data.Ring.Boolean newtype BoolRing BoolRing :: Bool -> BoolRing getBoolRing :: BoolRing -> Bool instance Eq BoolRing instance Ord BoolRing instance Show BoolRing instance Read BoolRing instance Arbitrary BoolRing instance CoArbitrary BoolRing instance Reducer Bool BoolRing instance Ring BoolRing instance SemiRing BoolRing instance RightSemiNearRing BoolRing instance LeftSemiNearRing BoolRing instance Multiplicative BoolRing instance Group BoolRing instance Monoid BoolRing -- | A wrapper that lies for you and claims any instance of Num is a -- Ring. Who knows, for your type it might even be telling the -- truth! module Data.Ring.FromNum newtype FromNum a FromNum :: a -> FromNum a getFromNum :: FromNum a -> a instance (Eq a) => Eq (FromNum a) instance (Show a) => Show (FromNum a) instance (Num a) => Num (FromNum a) instance (Arbitrary a) => Arbitrary (FromNum a) instance (CoArbitrary a) => CoArbitrary (FromNum a) instance (Num a) => Reducer Integer (FromNum a) instance (Num a) => Ring (FromNum a) instance (Num a) => SemiRing (FromNum a) instance (Num a) => RightSemiNearRing (FromNum a) instance (Num a) => LeftSemiNearRing (FromNum a) instance (Num a) => Multiplicative (FromNum a) instance (Num a) => Group (FromNum a) instance (Num a) => Monoid (FromNum a) module Data.Ring.ModularArithmetic data Mod a s class Modular s a | s -> a modulus :: (Modular s a) => s -> a withIntegralModulus :: (Integral a) => a -> (forall s. (Modular s a) => w Mod s) -> w instance (Eq a) => Eq (Mod a s) instance (Show a) => Show (Mod a s) instance (Modular s a, Integral a) => Ring (Mod a s) instance (Modular s a, Integral a) => SemiRing (Mod a s) instance (Modular s a, Integral a) => RightSemiNearRing (Mod a s) instance (Modular s a, Integral a) => LeftSemiNearRing (Mod a s) instance (Modular s a, Integral a) => Group (Mod a s) instance (Modular s a, Integral a) => Multiplicative (Mod a s) instance (Modular s a, Integral a) => Monoid (Mod a s) instance (Modular s a, Integral a) => Num (Mod a s) instance (ReflectedNum s, Num a) => Modular (ModulusNum s a) a -- | Left- and right- modules over rings, semirings, and Seminearrings. To -- avoid a proliferation of classes. These only require that there be an -- addition and multiplication operation for the Ring module Data.Ring.Module -- |
-- (x * y) *. m = x * (y *. m) --class (Monoid r, Multiplicative r, Monoid m) => LeftModule r m (*.) :: (LeftModule r m) => r -> m -> m -- |
-- (m .* x) * y = m .* (x * y) --class (Monoid r, Multiplicative r, Monoid m) => RightModule r m (.*) :: (RightModule r m) => m -> r -> m -- |
-- (x *. m) .* y = x *. (m .* y) --class (LeftModule r m, RightModule r m) => Module r m instance (Module r m, Module r n, Module r o, Module r p, Module r q) => Module r (m, n, o, p, q) instance (Module r m, Module r n, Module r o, Module r p) => Module r (m, n, o, p) instance (Module r m, Module r n, Module r o) => Module r (m, n, o) instance (Module r m, Module r n) => Module r (m, n) instance (RightModule r m, RightModule r n, RightModule r o, RightModule r p, RightModule r q) => RightModule r (m, n, o, p, q) instance (RightModule r m, RightModule r n, RightModule r o, RightModule r p) => RightModule r (m, n, o, p) instance (RightModule r m, RightModule r n, RightModule r o) => RightModule r (m, n, o) instance (RightModule r m, RightModule r n) => RightModule r (m, n) instance (LeftModule r m, LeftModule r n, LeftModule r o, LeftModule r p, LeftModule r q) => LeftModule r (m, n, o, p, q) instance (LeftModule r m, LeftModule r n, LeftModule r o, LeftModule r p) => LeftModule r (m, n, o, p) instance (LeftModule r m, LeftModule r n, LeftModule r o) => LeftModule r (m, n, o) instance (LeftModule r m, LeftModule r n) => LeftModule r (m, n) -- | Monoids for working with an Applicative Functor. module Data.Monoid.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 () -- | A Alt turns any Alternative instance into a -- Monoid. It also provides a Multiplicative instance for -- an Applicative functor wrapped around a Monoid and -- asserts that any Alternative applied to a Monoid forms a -- LeftSemiNearRing under these operations. newtype Alt f a Alt :: f a -> Alt f a getAlt :: Alt f a -> f a -- | if m is a Module over r and f is a -- Applicative then f App m is a Module -- over r as well newtype App f m App :: f m -> App f m getApp :: App f m -> f m -- | Efficiently avoid needlessly rebinding when using snoc on an -- action that already returns () A rewrite rule automatically applies -- this when possible snocTraversal :: (Reducer (f ()) (Traversal f)) => Traversal f -> f () -> Traversal f instance (Eq (f m)) => Eq (App f m) instance (Ord (f m)) => Ord (App f m) instance (Show (f m)) => Show (App f m) instance (Read (f m)) => Read (App f m) instance (Functor f) => Functor (App f) instance (Pointed f) => Pointed (App f) instance (Applicative f) => Applicative (App f) instance (Alternative f) => Alternative (App f) instance (Copointed f) => Copointed (App f) instance (Eq (f a)) => Eq (Alt f a) instance (Ord (f a)) => Ord (Alt f a) instance (Show (f a)) => Show (Alt f a) instance (Read (f a)) => Read (Alt f a) instance (Functor f) => Functor (Alt f) instance (Applicative f) => Applicative (Alt f) instance (Alternative f) => Alternative (Alt f) instance (Copointed f) => Copointed (Alt f) instance (Module r m, Applicative f) => Module r (App f m) instance (RightModule r m, Applicative f) => RightModule r (App f m) instance (LeftModule r m, Applicative f) => LeftModule r (App f m) instance (Reducer c m, Applicative f) => Reducer c (App f m) instance (Group m, Applicative f) => Group (App f m) instance (Monoid m, Applicative f) => Monoid (App f m) instance (Alternative f, Monoid a) => LeftSemiNearRing (Alt f a) instance (Alternative f) => Reducer (f a) (Alt f a) instance (Applicative f) => Pointed (Alt f) instance (Applicative f, Monoid a) => Multiplicative (Alt f a) instance (Alternative f) => Monoid (Alt f a) instance (Applicative f) => Reducer (f a) (Traversal f) instance (Applicative f) => Monoid (Traversal f) -- | Monoid instances for working with a Monad module Data.Monoid.Monad -- | An Action uses glues together Monad actions with -- (>>) in the manner of mapM_ from Data.Foldable. -- Any values returned by reduced actions are discarded. newtype Action m Action :: m () -> Action m getAction :: Action m -> m () -- | Efficiently avoid needlessly rebinding when using snoc on an -- action that already returns () A rewrite rule automatically applies -- this when possible snocAction :: (Reducer (m ()) (Action m)) => Action m -> m () -> Action m -- | A MonadSum turns any MonadPlus instance into a -- Monoid. It also provides a Multiplicative instance for a -- Monad wrapped around a Monoid and asserts that any -- MonadPlus applied to a Monoid forms a -- LeftSemiNearRing under these operations. newtype MonadSum m a MonadSum :: m a -> MonadSum m a getMonadSum :: MonadSum m a -> m a -- | if m is a Module over r and f is a -- Monad then f Mon m is a Module as well newtype Mon f m Mon :: f m -> Mon f m getMon :: Mon f m -> f m instance (Eq (f m)) => Eq (Mon f m) instance (Ord (f m)) => Ord (Mon f m) instance (Show (f m)) => Show (Mon f m) instance (Read (f m)) => Read (Mon f m) instance (Functor f) => Functor (Mon f) instance (Pointed f) => Pointed (Mon f) instance (Monad f) => Monad (Mon f) instance (MonadPlus f) => MonadPlus (Mon f) instance (Eq (m a)) => Eq (MonadSum m a) instance (Ord (m a)) => Ord (MonadSum m a) instance (Show (m a)) => Show (MonadSum m a) instance (Read (m a)) => Read (MonadSum m a) instance (Monad m) => Monad (MonadSum m) instance (MonadPlus m) => MonadPlus (MonadSum m) instance (Module r m, Monad f) => Module r (Mon f m) instance (RightModule r m, Monad f) => RightModule r (Mon f m) instance (LeftModule r m, Monad f) => LeftModule r (Mon f m) instance (Reducer c m, Monad f) => Reducer c (Mon f m) instance (Group m, Monad f) => Group (Mon f m) instance (Monoid m, Monad f) => Monoid (Mon f m) instance (MonadPlus m, Monoid a) => LeftSemiNearRing (MonadSum m a) instance (MonadPlus m) => Reducer (m a) (MonadSum m a) instance (Monad m) => Pointed (MonadSum m) instance (Monad m) => Applicative (MonadSum m) instance (Monad m) => Functor (MonadSum m) instance (Monad m, Monoid a) => Multiplicative (MonadSum m a) instance (MonadPlus m) => Monoid (MonadSum m a) instance (Monad m) => Reducer (m a) (Action m) instance (Monad m) => Monoid (Action m) -- | 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.Group.Combinators as Monoid --module Data.Monoid.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 Self -- monoid. A specialized version of its namesake from -- Data.Foldable -- --
-- mapReduceWith getSelf --foldMap :: (Monoid m, Generator c) => (Elem c -> m) -> c -> m -- | Efficiently reduce a Generator using the Self -- monoid. A specialized version of its namesake from -- Data.Foldable -- --
-- reduceWith getSelf --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) => (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) => (m -> n) -> (Elem c -> Bool) -> c -> n -- | A specialization of filter using the First -- Monoid, analogous to Data.List.find -- --
-- filterWith getFirst --find :: (Generator c) => (Elem c -> Bool) -> c -> Maybe (Elem c) -- | 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 generalization of Data.List.repeat to an arbitrary Monoid. -- May fail to terminate for some values in some monoids. repeat :: (Reducer e m) => e -> m -- | 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 :: (Monoid m, Integral n) => m -> n -> m -- | A generalization of Data.List.cycle to an arbitrary Monoid. May -- fail to terminate for some values in some monoids. cycle :: (Monoid m) => m -> m prop_replicate_right_distributive :: (Eq m, Monoid m, Arbitrary m, Integral n) => m -> n -> n -> Bool module Data.Monoid.Generator.Free data Free a AnyGenerator :: c -> Free a instance Generator (Free a) instance Foldable Free instance MonadPlus Free instance Monad Free instance Pointed Free instance Functor Free instance Reducer a (Free a) instance Monoid (Free a) instance (Ord a) => Ord (Free a) instance (Eq a) => Eq (Free a) -- | 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. module Data.Monoid.Generator.RLE -- | A Generator which supports efficient mapReduce -- operations over run-length encoded data. newtype RLE f a RLE :: f (Run a) -> RLE f a getRLE :: RLE f a -> f (Run a) -- | A single run with a strict length. data Run a Run :: a -> !!Int -> Run a decode :: (Foldable f) => RLE f a -> [a] encode :: (Generator c, Eq (Elem c)) => c -> RLE Seq (Elem c) -- | naive left to right encoder encodeList :: (Eq a) => [a] -> RLE [] a prop_decode_encode :: (Generator c, Eq (Elem c)) => c -> Bool -- | QuickCheck property: decode . encode = id prop_decode_encodeList :: (Eq a) => [a] -> Bool instance (Eq a) => Reducer a (RLE Seq a) instance (Eq a) => Monoid (RLE Seq a) instance (Foldable f) => Generator (RLE f a) instance (Functor f) => Functor (RLE f) instance Pointed Run instance Functor Run -- | Monoids for non-negative integers (Natural) and ints (Nat) -- -- The naturals form a module over any of our monoids. module Data.Ring.Semi.Natural data Natural natural :: Integer -> Natural instance Eq Natural instance Ord Natural instance (Multiplicative m) => Module Natural (Log m) instance (Multiplicative m) => RightModule Natural (Log m) instance (Multiplicative m) => LeftModule Natural (Log m) instance (CharReducer m) => Module Natural (UTF8 m) instance (CharReducer m) => RightModule Natural (UTF8 m) instance (CharReducer m) => LeftModule Natural (UTF8 m) instance Module Natural (SourcePosition f) instance RightModule Natural (SourcePosition f) instance LeftModule Natural (SourcePosition f) instance (MonadPlus f) => Module Natural (MonadSum f a) instance (MonadPlus f) => RightModule Natural (MonadSum f a) instance (MonadPlus f) => LeftModule Natural (MonadSum f a) instance (Monad f) => Module Natural (Action f) instance (Monad f) => RightModule Natural (Action f) instance (Monad f) => LeftModule Natural (Action f) instance (Alternative f) => Module Natural (Alt f a) instance (Alternative f) => RightModule Natural (Alt f a) instance (Alternative f) => LeftModule Natural (Alt f a) instance (Applicative f) => Module Natural (Traversal f) instance (Applicative f) => RightModule Natural (Traversal f) instance (Applicative f) => LeftModule Natural (Traversal f) instance (Monoid m) => Module Natural (CMonoid m m m) instance (Monoid m) => RightModule Natural (CMonoid m m m) instance (Monoid m) => LeftModule Natural (CMonoid m m m) instance (Category k) => Module Natural (GEndo k a) instance (Category k) => RightModule Natural (GEndo k a) instance (Category k) => LeftModule Natural (GEndo k a) instance (Eq a) => Module Natural (RLE Seq a) instance (Eq a) => RightModule Natural (RLE Seq a) instance (Eq a) => LeftModule Natural (RLE Seq a) instance Module Natural (Free a) instance RightModule Natural (Free a) instance LeftModule Natural (Free a) instance (Monoid m) => Module Natural (Self m) instance (Monoid m) => RightModule Natural (Self m) instance (Monoid m) => LeftModule Natural (Self m) instance (Monoid m) => Module Natural (FromString m) instance (Monoid m) => RightModule Natural (FromString m) instance (Monoid m) => LeftModule Natural (FromString m) instance (Monoid m) => Module Natural (Dual m) instance (Monoid m) => RightModule Natural (Dual m) instance (Monoid m) => LeftModule Natural (Dual m) instance Module Natural (Endo a) instance RightModule Natural (Endo a) instance LeftModule Natural (Endo a) instance (Num a) => Module Natural (Product a) instance (Num a) => RightModule Natural (Product a) instance (Num a) => LeftModule Natural (Product a) instance (Num a) => Module Natural (Sum a) instance (Num a) => RightModule Natural (Sum a) instance (Num a) => LeftModule Natural (Sum a) instance (Monoid m) => Module Natural (a -> m) instance (Monoid m) => RightModule Natural (a -> m) instance (Monoid m) => LeftModule Natural (a -> m) instance Module Natural [a] instance RightModule Natural [a] instance LeftModule Natural [a] instance Module Natural Ordering instance RightModule Natural Ordering instance LeftModule Natural Ordering instance Module Natural (Last a) instance RightModule Natural (Last a) instance LeftModule Natural (Last a) instance Module Natural (First a) instance RightModule Natural (First a) instance LeftModule Natural (First a) instance Module Natural All instance RightModule Natural All instance LeftModule Natural All instance Module Natural Any instance RightModule Natural Any instance LeftModule Natural Any instance Module Natural () instance RightModule Natural () instance LeftModule Natural () instance SemiRing Natural instance RightSemiNearRing Natural instance LeftSemiNearRing Natural instance Multiplicative Natural instance Monoid Natural instance Integral Natural instance Real Natural instance Enum Natural instance Num Natural instance Show Natural instance Read Natural module Data.Ring.Module.AutomaticDifferentiation data D r m instance (CoArbitrary r, CoArbitrary m) => CoArbitrary (D r m) instance (Arbitrary r, Arbitrary m) => Arbitrary (D r m) instance (Reducer c r, Reducer c m) => Reducer c (D r m) instance (Ring r, Module r m, Group m) => Ring (D r m) instance (SemiRing r, Module r m) => SemiRing (D r m) instance (RightSemiNearRing r, Module r m) => RightSemiNearRing (D r m) instance (LeftSemiNearRing r, Module r m) => LeftSemiNearRing (D r m) instance (Group r, Module r m, Group m) => Group (D r m) instance (Module r m) => Multiplicative (D r m) instance (Monoid r, Monoid m) => Monoid (D r m)