Modulecomonad-5.0.10
Control.Comonad.Traced
- 13 types
- 6 classes
- 16 values
- Packagecomonad-5.0.10
- Exports36
- LicenceBSD-3-Clause
- SourceFunctor.hs
Flipped version of <$.
Examples
Replace the contents of a Maybe Int with a constant
String:
Nothing $> "foo"Nothing
Just 90210 $> "foo"Just "foo"
Replace the contents of an Either Int Int
with a constant String, resulting in an Either
Int String:
Left 8675309 $> "foo"Left 8675309
Right 8675309 $> "foo"Right "foo"
Replace each element of a list with a constant String:
[1,2,3] $> "foo"["foo","foo","foo"]
Replace the second element of a pair with a constant String:
(1,2) $> "foo"(1,"foo")
An infix synonym for fmap.
The name of this operator is an allusion to Prelude.$.
Note the similarities between their types:
($) :: (a -> b) -> a -> b
(<$>) :: Functor f => (a -> b) -> f a -> f bWhereas Prelude.$ is function application, <$> is function
application lifted over a Functor.
Examples
Convert from a Maybe Int to a Maybe
String using show:
show <$> NothingNothing
show <$> Just 3Just "3"
Convert from an Either Int Int to an
Either Int String using show:
show <$> Left 17Left 17
show <$> Right 17Right "17"
Double each element of a list:
(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
even <$> (2,2)(2,True)
Constructors
CokleislirunCokleisli :: w a -> b
Instances8Category, Arrow, ArrowApply, ArrowChoice, ArrowLoop, Monad, …
Comonad w => Category (Cokleisli w)Defined in comonad-5.0.10 · Control.ComonadComonad w => Arrow (Cokleisli w)Defined in comonad-5.0.10 · Control.ComonadComonad w => ArrowApply (Cokleisli w)Defined in comonad-5.0.10 · Control.ComonadComonad w => ArrowChoice (Cokleisli w)Defined in comonad-5.0.10 · Control.ComonadComonadApply w => ArrowLoop (Cokleisli w)Defined in comonad-5.0.10 · Control.ComonadMonad (Cokleisli w a)Defined in comonad-5.0.10 · Control.ComonadFunctor (Cokleisli w a)Defined in comonad-5.0.10 · Control.ComonadApplicative (Cokleisli w a)Defined in comonad-5.0.10 · Control.Comonad
Instances12Comonad, …
Comonad TreeDefined in comonad-5.0.10 · Control.ComonadComonad NonEmptyDefined in comonad-5.0.10 · Control.ComonadComonad IdentityDefined in comonad-5.0.10 · Control.ComonadComonad (Arg e)Defined in comonad-5.0.10 · Control.ComonadComonad (Tuple2 e)Defined in comonad-5.0.10 · Control.ComonadComonad (Tagged s)Defined in comonad-5.0.10 · Control.ComonadComonad w => Comonad (EnvT e w)Defined in comonad-5.0.10 · Control.Comonad.Trans.EnvComonad w => Comonad (StoreT s w)Defined in comonad-5.0.10 · Control.Comonad.Trans.StoreComonad w => Comonad (IdentityT w)Defined in comonad-5.0.10 · Control.Comonad(Comonad w, Monoid m) => Comonad (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedMonoid m => Comonad ((->) m)Defined in comonad-5.0.10 · Control.Comonad(Comonad f, Comonad g) => Comonad (Sum f g)Defined in comonad-5.0.10 · Control.Comonad
Instances9ComonadApply, …
ComonadApply TreeDefined in comonad-5.0.10 · Control.ComonadComonadApply NonEmptyDefined in comonad-5.0.10 · Control.ComonadComonadApply IdentityDefined in comonad-5.0.10 · Control.ComonadSemigroup m => ComonadApply (Tuple2 m)Defined in comonad-5.0.10 · Control.ComonadComonadApply w => ComonadApply (IdentityT w)Defined in comonad-5.0.10 · Control.Comonad(ComonadApply w, Monoid m) => ComonadApply (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.Traced(ComonadApply w, Semigroup s) => ComonadApply (StoreT s w)Defined in comonad-5.0.10 · Control.Comonad.Trans.Store(Semigroup e, ComonadApply w) => ComonadApply (EnvT e w)Defined in comonad-5.0.10 · Control.Comonad.Trans.EnvMonoid m => ComonadApply ((->) m)Defined in comonad-5.0.10 · Control.Comonad
Methods
trace :: m -> w a -> a
Instances5ComonadTraced
ComonadTraced m w => ComonadTraced m (EnvT e w)Defined in comonad-5.0.10 · Control.Comonad.Traced.ClassComonadTraced m w => ComonadTraced m (StoreT s w)Defined in comonad-5.0.10 · Control.Comonad.Traced.ClassComonadTraced m w => ComonadTraced m (IdentityT w)Defined in comonad-5.0.10 · Control.Comonad.Traced.Class(Comonad w, Monoid m) => ComonadTraced m (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Traced.ClassMonoid m => ComonadTraced m ((->) m)Defined in comonad-5.0.10 · Control.Comonad.Traced.Class
Instances4ComonadTrans
ComonadTrans IdentityTDefined in comonad-5.0.10 · Control.Comonad.Trans.ClassComonadTrans (EnvT e)Defined in comonad-5.0.10 · Control.Comonad.Trans.EnvComonadTrans (StoreT s)Defined in comonad-5.0.10 · Control.Comonad.Trans.StoreMonoid m => ComonadTrans (TracedT m)Defined in comonad-5.0.10 · Control.Comonad.Trans.Traced
Constructors
TracedTrunTracedT :: w (m -> a)
Instances11ComonadEnv, ComonadStore, ComonadTraced, ComonadTrans, ComonadHoist, Functor, …
(ComonadEnv e w, Monoid m) => ComonadEnv e (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Env.Class(ComonadStore s w, Monoid m) => ComonadStore s (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Store.Class(Comonad w, Monoid m) => ComonadTraced m (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Traced.ClassMonoid m => ComonadTrans (TracedT m)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedComonadHoist (TracedT m)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedFunctor w => Functor (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedApplicative w => Applicative (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedDistributive w => Distributive (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.Traced(Comonad w, Monoid m) => Comonad (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.Traced(ComonadApply w, Monoid m) => ComonadApply (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedFunctorWithIndex i w => FunctorWithIndex (s, i) (TracedT s w)Defined in comonad-5.0.10 · Control.Comonad.Trans.Traced
A type f is a Functor if it provides a function fmap which, given any types a and b
lets you apply any function from (a -> b) to turn an f a into an f b, preserving the
structure of f. Furthermore f needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap and the first law, so you need only check that the former condition holds. See these articles by School of Haskell or David Luposchainsky for an explanation.
Methods
fmap :: (a -> b) -> f a -> f bfmap is used to apply a function of type
(a -> b)to a value of typef a, where f is a functor, to produce a value of typef b. Note that for any type constructor with more than one parameter (e.g.,Either), only the last type parameter can be modified with fmap (e.g.,binEither a b).Some type constructors with two parameters or more have a
Bifunctorinstance that allows both the last and the penultimate parameters to be mapped over.Examples
Convert from a
Maybe Intto aMaybe Stringusing show:Example2 expressions fmap show NothingNothingfmap show (Just 3)Just "3"
Convert from an
Either Int Intto anEither Int Stringusing show:Example2 expressions fmap show (Left 17)Left 17fmap show (Right 17)Right "17"
Double each element of a list:
Example1 expression fmap (*2) [1,2,3][2,4,6]
Apply even to the second element of a pair:
Example1 expression fmap even (2,2)(2,True)
It may seem surprising that the function is only applied to the last element of the tuple compared to the list example above which applies it to every element in the list. To understand, remember that tuples are type constructors with multiple type parameters: a tuple of 3 elements
(a,b,c)can also be written(,,) a b cand itsFunctorinstance is defined forFunctor ((,,) a b)(i.e., only the third parameter is free to be mapped over withfmap).It explains why
fmapcan be used with tuples containing values of different types as in the following example:Example1 expression fmap even ("hello", 1.0, 4)("hello",1.0,True)
(<$) :: a -> f b -> f ainfixl 4Replace all locations in the input with the same value. The default definition is
fmap . const, but this may be overridden with a more efficient version.Examples
Perform a computation with Maybe and replace the result with a constant value if it is Just:
Example2 expressions 'a' <$ Just 2Just 'a''a' <$ NothingNothing
Instances121Functor, …
Functor ComplexDefined in base-4.23.0.0 · Data.ComplexFunctor FirstDefined in base-4.23.0.0 · Data.SemigroupFunctor LastDefined in base-4.23.0.0 · Data.SemigroupFunctor MaxDefined in base-4.23.0.0 · Data.SemigroupFunctor MinDefined in base-4.23.0.0 · Data.SemigroupFunctor ArgDescrDefined in base-4.23.0.0 · System.Console.GetOptFunctor ArgOrderDefined in base-4.23.0.0 · System.Console.GetOptFunctor OptDescrDefined in base-4.23.0.0 · System.Console.GetOptFunctor SCCDefined in containers-0.8 · Data.GraphFunctor IntMapDefined in containers-0.8 · Data.IntMap.InternalFunctor DigitDefined in containers-0.8 · Data.Sequence.InternalFunctor ElemDefined in containers-0.8 · Data.Sequence.InternalFunctor FingerTreeDefined in containers-0.8 · Data.Sequence.InternalFunctor NodeDefined in containers-0.8 · Data.Sequence.InternalFunctor SeqDefined in containers-0.8 · Data.Sequence.InternalFunctor ViewLDefined in containers-0.8 · Data.Sequence.InternalFunctor ViewRDefined in containers-0.8 · Data.Sequence.InternalFunctor PostOrderDefined in containers-0.8 · Data.TreeFunctor TreeDefined in containers-0.8 · Data.TreeFunctor PprMDefined in ghc-boot-th-10.0.0.20260917 · GHC.Boot.TH.PprLibFunctor NonEmptyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.NonEmpty · orphanFunctor HandlerDefined in ghc-internal-10.0.0 · GHC.Internal.Control.ExceptionFunctor IdentityDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.IdentityFunctor FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor DownDefined in ghc-internal-10.0.0 · GHC.Internal.Data.OrdFunctor DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor ZipListDefined in ghc-internal-10.0.0 · GHC.Internal.Functor.ZipListFunctor NoIODefined in ghc-internal-10.0.0 · GHC.Internal.GHCiFunctor Par1Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor GenClosureDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ClosuresFunctor GenStackFieldDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ClosuresFunctor GenStackFrameDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ClosuresFunctor GenStgStackClosureDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ClosuresFunctor MaybeDefined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor STMDefined in ghc-internal-10.0.0 · GHC.Internal.STMFunctor QDefined in ghc-internal-10.0.0 · GHC.Internal.TH.MonadFunctor TyVarBndrDefined in ghc-internal-10.0.0 · GHC.Internal.TH.SyntaxFunctor PDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPFunctor ReadPDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPFunctor ReadPrecDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPrecFunctor SoloDefined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor IODefined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor AnnotDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJFunctor DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJFunctor SpanDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJFunctor []Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor ProxyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.ProxyFunctor U1Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor V1Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Arg a)Defined in base-4.23.0.0 · Data.SemigroupFunctor (Map k)Defined in containers-0.8 · Data.Map.InternalFunctor (State s)Defined in containers-0.8 · Utils.Containers.Internal.StateFunctor (Array i)Defined in ghc-internal-10.0.0 · GHC.Internal.ArrFunctor (ST s)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ST.Lazy.ImpFunctor (Either a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.EitherFunctor (StateL s)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.UtilsFunctor (StateR s)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.UtilsFunctor (ST s)Defined in ghc-internal-10.0.0 · GHC.Internal.STFunctor (Tuple2 a)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor f => Functor (Lift f)Defined in transformers-0.6.3.0 · Control.Applicative.LiftFunctor m => Functor (MaybeT m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.MaybeMonad m => Functor (WrappedMonad m)Defined in base-4.23.0.0 · Control.ApplicativeArrow a => Functor (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowFunctor (Const m)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.ConstFunctor (URec Char)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (URec Double)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (URec Float)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (URec Int)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (URec Word)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (URec (Ptr ()))Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Tuple3 a b)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor (Tagged s)Defined in tagged-0.8.11 · Data.TaggedFunctor (Constant a)Defined in transformers-0.6.3.0 · Data.Functor.ConstantFunctor f => Functor (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor f => Functor (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor f => Functor (Rec1 f)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor f => Functor (Indexing f)Defined in indexed-traversable-0.1.5 · WithIndexFunctor f => Functor (Backwards f)Defined in transformers-0.6.3.0 · Control.Applicative.BackwardsDerived instance.
Functor f => Functor (Reverse f)Defined in transformers-0.6.3.0 · Data.Functor.ReverseDerived instance.
Functor m => Functor (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowFunctor m => Functor (AccumT w m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.AccumFunctor m => Functor (ExceptT e m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.ExceptFunctor m => Functor (IdentityT m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.IdentityFunctor m => Functor (ReaderT r m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.ReaderFunctor m => Functor (SelectT r m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.SelectFunctor m => Functor (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.LazyFunctor m => Functor (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictFunctor m => Functor (WriterT w m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.CPSFunctor m => Functor (WriterT w m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.LazyFunctor m => Functor (WriterT w m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.StrictFunctor w => Functor (EnvT e w)Defined in comonad-5.0.10 · Control.Comonad.Trans.EnvFunctor w => Functor (StoreT s w)Defined in comonad-5.0.10 · Control.Comonad.Trans.StoreFunctor w => Functor (TracedT m w)Defined in comonad-5.0.10 · Control.Comonad.Trans.TracedMonad m => Functor (StateT s m)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.UtilsArrow a => Functor (WrappedArrow a b)Defined in base-4.23.0.0 · Control.Applicative(Applicative f, Monad f) => Functor (WhenMissing f x)Defined in containers-0.8 · Data.IntMap.Internal(Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Cokleisli w a)Defined in comonad-5.0.10 · Control.ComonadFunctor (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Tuple4 a b c)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor (ContT r m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.ContFunctor ((->) r)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor f => Functor (WhenMatched f x y)Defined in containers-0.8 · Data.IntMap.Internal(Applicative f, Monad f) => Functor (WhenMissing f k x)Defined in containers-0.8 · Data.Map.Internal(Functor f, Functor g) => Functor (Product f g)Defined in base-4.23.0.0 · Data.Functor.Product(Functor f, Functor g) => Functor (Sum f g)Defined in base-4.23.0.0 · Data.Functor.Sum(Functor f, Functor g) => Functor (f :*: g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics(Functor f, Functor g) => Functor (f :+: g)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Tuple5 a b c d)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor f => Functor (WhenMatched f k x y)Defined in containers-0.8 · Data.Map.InternalFunctor f => Functor (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor m => Functor (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.CPSFunctor m => Functor (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.LazyFunctor m => Functor (RWST r w s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Strict(Functor f, Functor g) => Functor (Compose f g)Defined in base-4.23.0.0 · Data.Functor.Compose(Functor f, Functor g) => Functor (f :.: g)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsFunctor (Tuple6 a b c d e)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseFunctor (Tuple7 a b c d e f)Defined in ghc-internal-10.0.0 · GHC.Internal.Base
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
- Right identity
- Left identity
- Associativity
(
law)
- Concatenation
You can alternatively define mconcat instead of mempty, in which case the laws are:
- Unit
- Multiplication
- Subclass
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtypes and make those instances
of Monoid, e.g. Data.Semigroup.Sum and Data.Semigroup.Product.
NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.
Methods
mempty :: aIdentity of mappend
Examples
Example1 expression "Hello world" <> mempty"Hello world"
Example1 expression mempty <> [1, 2, 3][1,2,3]
mappend :: a -> a -> aAn associative operation
NOTE: This method is redundant and has the default implementation
mappend = (<>)since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.mconcat :: [a] -> aFold a list using the monoid.
For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.
Example1 expression mconcat ["Hello", " ", "Haskell", "!"]"Hello Haskell!"
Instances72Monoid, …
Monoid ByteArrayDefined in base-4.23.0.0 · Data.Array.ByteMonoid IntSetDefined in containers-0.8 · Data.IntSet.Internalmempty= emptyMonoid UnitDefined in deepseq-1.5.2.0 · Control.DeepSeqMonoid AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid EventDefined in ghc-internal-10.0.0 · GHC.Internal.Event.Internal.TypesMonoid EventLifetimeDefined in ghc-internal-10.0.0 · GHC.Internal.Event.Internal.TypesMonoid LifetimeDefined in ghc-internal-10.0.0 · GHC.Internal.Event.Internal.Typesmappendtakes the longer of two lifetimes.Monoid ExceptionContextDefined in ghc-internal-10.0.0 · GHC.Internal.Exception.ContextMonoid OrderingDefined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJMonoid ()Defined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid (Comparison a)Defined in base-4.23.0.0 · Data.Functor.ContravariantMonoid (Equivalence a)Defined in base-4.23.0.0 · Data.Functor.ContravariantMonoid (Predicate a)Defined in base-4.23.0.0 · Data.Functor.ContravariantMonoid (IntMap a)Defined in containers-0.8 · Data.IntMap.Internalmempty= emptyMonoid (Seq a)Defined in containers-0.8 · Data.Sequence.Internalmempty= emptyMonoid (MergeSet a)Defined in containers-0.8 · Data.Set.InternalMonoid (EqM a)Defined in containers-0.8 · Utils.Containers.Internal.EqOrdUtilMonoid (OrdM a)Defined in containers-0.8 · Utils.Containers.Internal.EqOrdUtilMonoid (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonoid (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonoid (Endo a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJMonoid [a]Defined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid a => Monoid (Identity a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.IdentityMonoid a => Monoid (Down a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.OrdMonoid a => Monoid (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid a => Monoid (STM a)Defined in ghc-internal-10.0.0 · GHC.Internal.STMMonoid a => Monoid (Q a)Defined in ghc-internal-10.0.0 · GHC.Internal.TH.MonadMonoid a => Monoid (IO a)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid a => Monoid (a)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid m => Monoid (WrappedMonoid m)Defined in base-4.23.0.0 · Data.SemigroupMonoid p => Monoid (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup a => Monoid (Maybe a)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseLift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup
Smay be turned into a monoid simply by adjoining an elementenot inSand defininge*e = eande*s = s = s*efor alls ∈ S."Since 4.11.0: constraint on inner
avalue generalised from Monoid to Semigroup.Bits a => Monoid (Ior a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.BitsBits a => Monoid (Xor a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.BitsFiniteBits a => Monoid (And a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.BitsThis constraint is arguably too strong. However, as some types (such as
Natural) have undefined complement, this is the only safe choice.FiniteBits a => Monoid (Iff a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.BitsThis constraint is arguably too strong. However, as some types (such as
Natural) have undefined complement, this is the only safe choice.Ord a => Monoid (Set a)Defined in containers-0.8 · Data.Set.Internalmempty= emptyOrd a => Monoid (Max a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.UtilsOrd a => Monoid (Min a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.UtilsNum a => Monoid (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNum a => Monoid (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.Internal(Ord a, Bounded a) => Monoid (Max a)Defined in base-4.23.0.0 · Data.Semigroup(Ord a, Bounded a) => Monoid (Min a)Defined in base-4.23.0.0 · Data.Semigroup(Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonoid (Proxy s)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.ProxyMonoid (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonoid a => Monoid (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariantmempty @(Op a b)without newtypes ismempty @(b->a)=_ -> mempty.mempty :: Op a b mempty = Op _ -> memptyMonoid a => Monoid (ST s a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ST.Lazy.ImpMonoid a => Monoid (ST s a)Defined in ghc-internal-10.0.0 · GHC.Internal.STMonoid b => Monoid (a -> b)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseOrd k => Monoid (Map k v)Defined in containers-0.8 · Data.Map.Internalmempty= empty(Monoid a, Monoid b) => Monoid (a, b)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseAlternative f => Monoid (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalApplicative f => Monoid (Traversed a f)Defined in indexed-traversable-0.1.5 · WithIndexMonad m => Monoid (Sequenced a m)Defined in indexed-traversable-0.1.5 · WithIndexMonoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonoid a => Monoid (Const a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Functor.ConstMonoid a => Monoid (Constant a b)Defined in transformers-0.6.3.0 · Data.Functor.Constant(Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Monoid(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)Defined in ghc-internal-10.0.0 · GHC.Internal.Base(Semigroup a, Monoid a) => Monoid (Tagged s a)Defined in tagged-0.8.11 · Data.TaggedMonoid c => Monoid (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics(Monoid (f a), Monoid (g a)) => Monoid (Product f g a)Defined in base-4.23.0.0 · Data.Functor.Product(Monoid (f p), Monoid (g p)) => Monoid ((:*:) f g p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)Defined in ghc-internal-10.0.0 · GHC.Internal.BaseMonoid (f (g a)) => Monoid (Compose f g a)Defined in base-4.23.0.0 · Data.Functor.ComposeMonoid (f (g p)) => Monoid ((:.:) f g p)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)Defined in ghc-internal-10.0.0 · GHC.Internal.Base
An associative operation.
Examples
[1,2,3] <> [4,5,6][1,2,3,4,5,6]
Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
putStr "Hello, " <> putStrLn "World!"Hello, World!
This data type witnesses the lifting of a Monoid into an Applicative pointwise.
Examples
Ap (Just [1, 2, 3]) <> Ap NothingAp {getAp = Nothing}
Ap [Sum 10, Sum 20] <> Ap [Sum 1, Sum 2]Ap {getAp = [Sum {getSum = 11},Sum {getSum = 12},Sum {getSum = 21},Sum {getSum = 22}]}
Instances24Generic1, Monad, Functor, MonadFix, MonadFail, Applicative, …
Generic1 (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonad f => Monad (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor f => Functor (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonadFix f => MonadFix (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixMonadFail f => MonadFail (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidApplicative f => Applicative (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFoldable f => Foldable (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable f => Traversable (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableAlternative f => Alternative (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonadPlus f => MonadPlus (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFoldable1 f => Foldable1 (Ap f)Defined in base-4.23.0.0 · Data.Foldable1(Applicative f, Bounded a) => Bounded (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidEnum (f a) => Enum (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidEq (f a) => Eq (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Monoid(Data (f a), Data a, Typeable f) => Data (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data(Applicative f, Num a) => Num (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidNote that even if the underlying Num and Applicative instances are lawful, for most Applicatives, this instance will not be lawful. If you use this instance with the list Applicative, the following customary laws will not hold:
Commutativity:
Example2 expressions Ap [10,20] + Ap [1,2]Ap {getAp = [11,12,21,22]}Ap [1,2] + Ap [10,20]Ap {getAp = [11,21,12,22]}
Additive inverse:
Example2 expressions Ap [] + negate (Ap [])Ap {getAp = []}fromInteger 0 :: Ap [] IntAp {getAp = [0]}
Distributivity:
Example2 expressions Ap [1,2] * (3 + 4)Ap {getAp = [7,14]}(Ap [1,2] * 3) + (Ap [1,2] * 4)Ap {getAp = [7,11,10,14]}
Ord (f a) => Ord (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidRead (f a) => Read (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidShow (f a) => Show (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidGeneric (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics(Applicative f, Semigroup a) => Semigroup (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Monoid(Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Monoidtype Rep (Ap f a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Ap"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"Ap"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAp"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))type Rep1 (Ap f) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Ap"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"Ap"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAp"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
Maybe monoid returning the leftmost non-Nothing value.
First a is isomorphic to Alt Maybe a, but precedes it
historically.
Beware that Data.Monoid.First is different from
Data.Semigroup.First. The former returns the first non-Nothing,
so Data.Monoid.First Nothing <> x = x. The latter simply returns the first value,
thus Data.Semigroup.First Nothing <> x = Data.Semigroup.First Nothing.
Examples
First (Just "hello") <> First Nothing <> First (Just "world")First {getFirst = Just "hello"}
First Nothing <> memptyFirst {getFirst = Nothing}
Instances20Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonadFix FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFoldable FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableMonadZip FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipNFData1 FirstDefined in deepseq-1.5.2.0 · Control.DeepSeqGeneric1 FirstDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsEq a => Eq (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidData a => Data (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataOrd a => Ord (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidRead a => Read (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidShow a => Show (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidGeneric (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonoid (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidNFData a => NFData (First a)Defined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep (First a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"First"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"First"
'PrefixI 'True) (S1 ('MetaSel ('Just"getFirst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))type Rep1 First = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"First"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"First"
'PrefixI 'True) (S1 ('MetaSel ('Just"getFirst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
Maybe monoid returning the rightmost non-Nothing value.
Last a is isomorphic to Dual (First a), and thus to
Dual (Alt Maybe a)
Data.Semigroup.Last. The former returns the last non-Nothing,
so x <> Data.Monoid.Last Nothing = x. The latter simply returns the last value,
thus x <> Data.Semigroup.Last Nothing = Data.Semigroup.Last Nothing.
Examples
Last (Just "hello") <> Last Nothing <> Last (Just "world")Last {getLast = Just "world"}
Last Nothing <> memptyLast {getLast = Nothing}
Instances20Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFunctor LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonadFix LastDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidFoldable LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable LastDefined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableMonadZip LastDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipNFData1 LastDefined in deepseq-1.5.2.0 · Control.DeepSeqGeneric1 LastDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsEq a => Eq (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidData a => Data (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataOrd a => Ord (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidRead a => Read (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidShow a => Show (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidGeneric (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidMonoid (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.MonoidNFData a => NFData (Last a)Defined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep (Last a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Last"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"Last"
'PrefixI 'True) (S1 ('MetaSel ('Just"getLast"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))type Rep1 Last = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Last"
"GHC.Internal.Data.Monoid"
"ghc-internal"
'True) (C1 ('MetaCons"Last"
'PrefixI 'True) (S1 ('MetaSel ('Just"getLast"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
Boolean monoid under conjunction (&&).
All x <> All y = All (x && y)Examples
All True <> mempty <> All False)All {getAll = False}
mconcat (map (\x -> All (even x)) [2,4,6,7,8])All {getAll = False}
All True <> memptyAll {getAll = True}
Instances11Bounded, Eq, Data, Ord, Read, Show, …
Bounded AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalData AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.DataOrd AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric AllDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid AllDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNFData AllDefined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep All = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"All"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"All"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAll"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
Monoid under <|>.
Alt l <> Alt r == Alt (l <|> r)Examples
Alt (Just 12) <> Alt (Just 24)Alt {getAlt = Just 12}
Alt Nothing <> Alt (Just 24)Alt {getAlt = Just 24}
Instances24Generic1, Monad, Functor, MonadFix, Applicative, Foldable, …
Generic1 (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsMonad f => Monad (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor f => Functor (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadFix f => MonadFix (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative f => Applicative (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFoldable f => Foldable (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable f => Traversable (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableAlternative f => Alternative (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadPlus f => MonadPlus (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadZip f => MonadZip (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipFoldable1 f => Foldable1 (Alt f)Defined in base-4.23.0.0 · Data.Foldable1Contravariant f => Contravariant (Alt f)Defined in base-4.23.0.0 · Data.Functor.ContravariantEnum (f a) => Enum (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq (f a) => Eq (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.Internal(Data (f a), Data a, Typeable f) => Data (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataNum (f a) => Num (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalOrd (f a) => Ord (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead (f a) => Read (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow (f a) => Show (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsAlternative f => Semigroup (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalAlternative f => Monoid (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.Internaltype Rep (Alt f a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Alt"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Alt"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAlt"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))type Rep1 (Alt f) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Alt"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Alt"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAlt"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
Boolean monoid under disjunction (||).
Any x <> Any y = Any (x || y)Examples
Any True <> mempty <> Any FalseAny {getAny = True}
mconcat (map (\x -> Any (even x)) [2,4,6,7,8])Any {getAny = True}
Any False <> memptyAny {getAny = False}
Instances11Bounded, Eq, Data, Ord, Read, Show, …
Bounded AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalData AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.DataOrd AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric AnyDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNFData AnyDefined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep Any = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Any"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Any"
'PrefixI 'True) (S1 ('MetaSel ('Just"getAny"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
The dual of a Monoid, obtained by swapping the arguments of (<>).
Dual a <> Dual b == Dual (b <> a)Examples
Dual "Hello" <> Dual "World"Dual {getDual = "WorldHello"}
Dual (Dual "Hello") <> Dual (Dual "World")Dual {getDual = Dual {getDual = "HelloWorld"}}
Instances23Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadFix DualDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFoldable DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable DualDefined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableMonadZip DualDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipFoldable1 DualDefined in base-4.23.0.0 · Data.Foldable1NFData1 DualDefined in deepseq-1.5.2.0 · Control.DeepSeqDistributive DualDefined in distributive-0.6.3 · Data.DistributiveGeneric1 DualDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsBounded a => Bounded (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq a => Eq (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalData a => Data (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataOrd a => Ord (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow a => Show (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup a => Semigroup (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid a => Monoid (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNFData a => NFData (Dual a)Defined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep (Dual a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Dual"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Dual"
'PrefixI 'True) (S1 ('MetaSel ('Just"getDual"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))type Rep1 Dual = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Dual"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Dual"
'PrefixI 'True) (S1 ('MetaSel ('Just"getDual"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
The monoid of endomorphisms under composition.
Endo f <> Endo g == Endo (f . g)Examples
let computation = Endo ("Hello, " ++) <> Endo (++ "!")appEndo computation "Haskell""Hello, Haskell!"
let computation = Endo (*3) <> Endo (+1)appEndo computation 16
Instances4Generic, Semigroup, Monoid, Rep
Generic (Endo a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsSemigroup (Endo a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonoid (Endo a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.Internaltype Rep (Endo a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Endo"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Endo"
'PrefixI 'True) (S1 ('MetaSel ('Just"appEndo"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a -> a))))
Monoid under multiplication.
Product x <> Product y == Product (x * y)Examples
Product 3 <> Product 4 <> memptyProduct {getProduct = 12}
mconcat [ Product n | n <- [2 .. 10]]Product {getProduct = 3628800}
Constructors
ProductgetProduct :: a
Instances24Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadFix ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFoldable ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableMonadZip ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipFoldable1 ProductDefined in base-4.23.0.0 · Data.Foldable1NFData1 ProductDefined in deepseq-1.5.2.0 · Control.DeepSeqDistributive ProductDefined in distributive-0.6.3 · Data.DistributiveGeneric1 ProductDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsBounded a => Bounded (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq a => Eq (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalData a => Data (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataNum a => Num (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalOrd a => Ord (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow a => Show (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsNum a => Semigroup (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNum a => Monoid (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNFData a => NFData (Product a)Defined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep (Product a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Product"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Product"
'PrefixI 'True) (S1 ('MetaSel ('Just"getProduct"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))type Rep1 Product = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Product"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Product"
'PrefixI 'True) (S1 ('MetaSel ('Just"getProduct"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Monoid under addition.
Sum a <> Sum b = Sum (a + b)Examples
Sum 1 <> Sum 2 <> memptySum {getSum = 3}
mconcat [ Sum n | n <- [3 .. 9]]Sum {getSum = 42}
Instances24Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
Monad SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFunctor SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalMonadFix SumDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixApplicative SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalFoldable SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.FoldableTraversable SumDefined in ghc-internal-10.0.0 · GHC.Internal.Data.TraversableMonadZip SumDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.ZipFoldable1 SumDefined in base-4.23.0.0 · Data.Foldable1NFData1 SumDefined in deepseq-1.5.2.0 · Control.DeepSeqDistributive SumDefined in distributive-0.6.3 · Data.DistributiveGeneric1 SumDefined in ghc-internal-10.0.0 · GHC.Internal.GenericsBounded a => Bounded (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalEq a => Eq (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalData a => Data (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.DataNum a => Num (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalOrd a => Ord (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalShow a => Show (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.GenericsNum a => Semigroup (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNum a => Monoid (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Semigroup.InternalNFData a => NFData (Sum a)Defined in deepseq-1.5.2.0 · Control.DeepSeqtype Rep (Sum a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Sum"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Sum"
'PrefixI 'True) (S1 ('MetaSel ('Just"getSum"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))type Rep1 Sum = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Generics"Sum"
"GHC.Internal.Data.Semigroup.Internal"
"ghc-internal"
'True) (C1 ('MetaCons"Sum"
'PrefixI 'True) (S1 ('MetaSel ('Just"getSum"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))