msum -package:singletons-base
base Control.Monad Data.Foldable,
base-compat Control.Monad.Compat,
protolude Protolude,
ihaskell IHaskellPrelude,
numhask NumHask.Prelude,
base-compat-batteries Control.Monad.Compat,
Agda Agda.Utils.Monad,
ghc-internal GHC.Internal.Control.Monad GHC.Internal.Data.Foldable,
rebase Rebase.Prelude,
massiv-test Test.Massiv.Utils,
LambdaHack Game.LambdaHack.Core.Prelude,
faktory Faktory.Prelude,
calligraphy Calligraphy.Prelude The sum of a collection of actions using
(<|>),
generalizing
concat.
msum is just like
asum, but specialised to
MonadPlus.
Examples
Basic usage, using the
MonadPlus instance for
Maybe:
>>> msum [Just "Hello", Nothing, Just "World"]
Just "Hello"
The sum of a collection of actions, generalizing
concat. As of
base 4.8.0.0,
msum is just
asum, specialized to
MonadPlus.
The sum of a collection of actions, generalizing
concat. As of
base 4.8.0.0,
msum is just
asum, specialized to
MonadPlus.
The sum of a collection of actions.
>>> msumOf each ("hello","world")
"helloworld"
>>> msumOf each (Nothing, Just "hello", Nothing)
Just "hello"
msum ≡ msumOf folded
Fold a structure with
>| (
|<), thus always
applying the input to the first (last) item for generation.
Try a list of monoidal actions in sequence, producing the index of the
first successful action, and evaluating the action with the given
index.
Fold a structure with
>| (
|<), thus always
applying the input to the first (last) item for generation.
A description, or caption, for this media.
A dual of
lensProduct: a prism sum.
The law
preview l (review l b) ≡ Just b
breaks with
>>> let badPrism :: Prism' (Maybe Char) (Either Char Char); badPrism = prismSum _Just _Just
>>> preview badPrism (review badPrism (Right 'x'))
Just (Left 'x')
We put in
Right value, but get back
Left.
Are you looking for
without?
An optional, string summary, intended to apply to all operations in
this path.
Apply update functions to the terms and coefficients of a weighted
sum.
This Haskell module exports various "from" functions for
Either
and
Maybe.
Extract a value from a
SumType
Example:
type Animal = SumType '[Owl, Cat, Toad]
let someAnimal = ... :: Animal
fromSumType (Proxy :: Proxy 0) someAnimal :: Maybe Owl
fromSumType (Proxy :: Proxy 1) someAnimal :: Maybe Cat
fromSumType (Proxy :: Proxy 2) someAnimal :: Maybe Toad
-- Compile-time error
-- fromSumType (Proxy :: Proxy 3) someAnimal