class Alt f => Plus f
Laws:
zero <!> m = m
m <!> zero = mIf extended to an Alternative then zero should equal empty.
class Alt f => Plus fLaws:
zero <!> m = m
m <!> zero = mIf extended to an Alternative then zero should equal empty.
zero :: f apsum :: (Foldable t, Plus f) => t (f a) -> f aThe sum of a collection of actions, generalizing concat.
>>> psum [Just "Hello", Nothing, Just "World"]
Just "Hello"gzero :: (Plus (Rep1 f), Generic1 f) => f aGeneric zero. Caveats:
Will not compile if f is a sum type.
Any types where the a does not appear must have a Monoid instance.
($>) :: (Functor f) => f a -> b -> f bReplace every value with the given one.
(<$>) :: (Functor f) => (a -> b) -> f a -> f b(<*.>) :: (Apply f) => MaybeApply f (a -> b) -> f a -> f bApply a possibly-empty-with-unit container of functions to a non-empty container of values.
(<.*>) :: (Apply f) => f (a -> b) -> MaybeApply f a -> f bApply a non-empty container of functions to a possibly-empty-with-unit container of values.
(<..>) :: Apply w => w a -> w (a -> b) -> w bA variant of <.> with the arguments reversed.
galt :: (Generic1 f, Alt (Rep1 f)) => f a -> f a -> f aGeneric (<!>). Caveats:
Will not compile if f is a sum type.
Any types where the a does not appear must have a Semigroup instance.
gliftF2 :: (Generic1 w, Apply (Rep1 w)) => (a -> b -> c) -> w a -> w b -> w cGeneric liftF2. Caveats:
Will not compile if w is a sum type.
Types in w that do not mention the type variable must be instances of Semigroup.
gliftF3 :: (Generic1 w, Apply (Rep1 w)) => (a -> b -> c -> d) -> w a -> w b -> w c -> w dGeneric liftF3. Caveats are the same as for gliftF2.
liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w dLift a ternary function into a comonad with zipping
class Functor f => Alt fLaws:
<!> is associative: (a <!> b) <!> c = a <!> (b <!> c)
<$> left-distributes over <!>: f <$> (a <!> b) = (f <$> a) <!> (f <$> b)If extended to an Alternative then <!> should equal <|>.
Ideally, an instance of Alt also satisfies the "left distribution" law of
MonadPlus with respect to <.>:
<.> right-distributes over <!>: (a <!> b) <.> c = (a <.> c) <!> (b <.> c)IO, , Either a and ExceptT e mSTM instead satisfy the
"left catch" law:
pure a <!> b = pure aMaybe and Identity satisfy both "left distribution" and "left catch".
These variations cannot be stated purely in terms of the dependencies of Alt.
When and if MonadPlus is successfully refactored, this class should also be refactored to remove these instances.
The right distributive law should extend in the cases where the a Bind or Monad is
provided to yield variations of the right distributive law:
(m <!> n) >>- f = (m >>- f) <!> (m >>- f)
(m <!> n) >>= f = (m >>= f) <!> (m >>= f)(<!>) :: f a -> f a -> f a<|> without a required empty
some :: Applicative f => f a -> f [a]many :: Applicative f => f a -> f [a]class Functor f => Apply fA strong lax semi-monoidal endofunctor.
This is equivalent to an Applicative without pure.
Laws:
('.') '<$>' u '<.>' v '<.>' w = u '<.>' (v '<.>' w)
x '<.>' (f '<$>' y) = ('.' f) '<$>' x '<.>' y
f '<$>' (x '<.>' y) = (f '.') '<$>' x '<.>' y
The laws imply that `.>` and `<.` really ignore their left and right results, respectively, and really return their right and left results, respectively. Specifically,
(mf '<$>' m) '.>' (nf '<$>' n) = nf '<$>' (m '.>' n)
(mf '<$>' m) '<.' (nf '<$>' n) = mf '<$>' (m '<.' n)
(<.>) :: f (a -> b) -> f a -> f b(.>) :: f a -> f b -> f b a .> b = const id <$> a <.> b
(<.) :: f a -> f b -> f a a <. b = const <$> a <.> b
liftF2 :: (a -> b -> c) -> f a -> f b -> f cLift a binary function into a comonad with zipping
class Functor (f :: Type -> Type)fmap :: (a -> b) -> f a -> f b(<$) :: a -> f b -> f anewtype MaybeApply f aTransform an Apply into an Applicative by adding a unit.
MaybeApply :: Either (f a) a -> MaybeApply f arunMaybeApply :: MaybeApply f a -> Either (f a) anewtype WrappedApplicative f aWrap an Applicative to be used as a member of Apply
WrapApplicative :: f a -> WrappedApplicative f aunwrapApplicative :: WrappedApplicative f a -> f ainstance Plus Proxyinstance Plus U1instance (Monoid c) => Plus (K1 i c)instance (Plus f, Plus g) => Plus (f :*: g)instance (Plus f, Functor g) => Plus (f :.: g)instance Plus f => Plus (M1 i c f)instance Plus f => Plus (Rec1 f)instance Plus IOinstance Plus []instance Plus Maybeinstance MonadPlus m => Plus (WrappedMonad m)instance ArrowPlus a => Plus (WrappedArrow a b)instance Ord k => Plus (Map k)instance Plus IntMapinstance Plus Seqinstance (Hashable k, Eq k) => Plus (HashMap k)instance Alternative f => Plus (WrappedApplicative f)instance Plus f => Plus (IdentityT f)instance Plus f => Plus (ReaderT e f)instance (Functor f, Monad f) => Plus (MaybeT f)instance (Functor f, Monad f, Semigroup e, Monoid e) => Plus (ExceptT e f)instance Plus f => Plus (Strict.StateT e f)instance Plus f => Plus (Lazy.StateT e f)instance Plus f => Plus (Strict.WriterT w f)instance Plus f => Plus (Lazy.WriterT w f)instance (Plus f) => Plus (CPS.WriterT w f)instance Plus f => Plus (Strict.RWST r w s f)instance Plus f => Plus (Lazy.RWST r w s f)instance (Plus f) => Plus (CPS.RWST r w s f)instance Plus f => Plus (Backwards f)instance (Plus f, Functor g) => Plus (Compose f g)instance Plus f => Plus (Lift f)instance (Plus f, Plus g) => Plus (Product f g)instance Plus f => Plus (Reverse f)instance Plus Monoid.Firstinstance Plus Monoid.LastCommunity contribution. The service has not verified this documentation.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-858b1951-web-1
Metadata snapshot: 4ac4693dc44e2bb370a93502d1bf29784374032a00ad7b3d02803e3d433c0b16
Open the dependency plan · Download the documentation model