Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Invariant monoidal functors.
This roughly corresponds to Control.Applicative, but exposes a non-overlapping API so can be imported unqualified. It does, however, use operators similar to those provided by contravariant.
- (>$<) :: Functor f => (a <-> b) -> f a -> f b
- class Functor f => Monoidal f where
- (>*) :: Monoidal f => f a -> f () -> f a
- (*<) :: Monoidal f => f () -> f a -> f a
- liftI2 :: Monoidal f => ((a, b) <-> c) -> f a -> f b -> f c
- liftI3 :: Monoidal f => ((a, b, c) <-> d) -> f a -> f b -> f c -> f d
- liftI4 :: Monoidal f => ((a, b, c, d) <-> e) -> f a -> f b -> f c -> f d -> f e
- liftI5 :: Monoidal f => ((a, b, c, d, e) <-> g) -> f a -> f b -> f c -> f d -> f e -> f g
- (>*<<) :: Monoidal f => f a -> f (b, c) -> f (a, b, c)
- (>*<<<) :: Monoidal f => f a -> f (b, c, d) -> f (a, b, c, d)
- (>*<<<<) :: Monoidal f => f a -> f (b, c, d, e) -> f (a, b, c, d, e)
- (>>*<) :: Monoidal f => f (a, b) -> f c -> f (a, b, c)
- (>>>*<) :: Monoidal f => f (a, b, c) -> f d -> f (a, b, c, d)
- (>>>>*<) :: Monoidal f => f (a, b, c, d) -> f e -> f (a, b, c, d, e)
- (>>*<<) :: Monoidal f => f (a, b) -> f (c, d) -> f (a, b, c, d)
- pureI :: Monoidal f => a -> f a
- sequenceMaybesI :: Monoidal f => [f (Maybe a)] -> f [a]
- mapMaybeI :: Monoidal f => (a -> f (Maybe b)) -> [a] -> f [b]
- class Monoidal f => MonoidalAlt f where
- possible :: MonoidalAlt f => f a -> f (Maybe a)
- defaulting :: (MonoidalAlt f, Eq a) => a -> f a -> f a
- while :: MonoidalAlt f => f a -> f [a]
Functor
(>$<) :: Functor f => (a <-> b) -> f a -> f b infixl 4 Source
Another synonym for fmap
to match other operators in this module.
Monoidal
class Functor f => Monoidal f where Source
Lax invariant monoidal functor.
This roughly corresponds to Applicative
, which, for covariant functors, is equivalent to a monoidal functor.
Invariant functors, however, may admit a monoidal instance but not applicative.
(>*) :: Monoidal f => f a -> f () -> f a infixl 4 Source
Sequence actions, discarding/inhabiting the unit value of the second argument.
(*<) :: Monoidal f => f () -> f a -> f a infixl 4 Source
Sequence actions, discarding/inhabiting the unit value of the first argument.
Tuple combinators
liftI2 :: Monoidal f => ((a, b) <-> c) -> f a -> f b -> f c Source
Lift an (uncurried) bijection into a monoidal functor.
pureI :: Monoidal f => a -> f a Source
A constant monoidal (like pure
), which always produces the same value and ignores everything.
sequenceMaybesI :: Monoidal f => [f (Maybe a)] -> f [a] Source
MonoidalAlt
class Monoidal f => MonoidalAlt f where Source
Monoidal functors that allow choice.
possible :: MonoidalAlt f => f a -> f (Maybe a) Source
Analogous to optional
.
defaulting :: (MonoidalAlt f, Eq a) => a -> f a -> f a Source
Return a default value if a monoidal functor fails, and only apply it to non-default values.
while :: MonoidalAlt f => f a -> f [a] Source
Repeatedly apply a monoidal functor until it fails. Analogous to many
.