Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- class Applicative m => Monad (m :: * -> *) where
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (<$!>) :: Monad m => (a -> b) -> m a -> m b
- join :: Monad m => m (m a) -> m a
- loopM :: Monad m => (a -> m (Either a b)) -> a -> m b
- unlessM :: Monad m => m Bool -> m () -> m ()
- whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()
- whenM :: Monad m => m Bool -> m () -> m ()
- whileM :: Monad m => m Bool -> m ()
- newtype Kleisli (m :: * -> *) a b = Kleisli {
- runKleisli :: a -> m b
- class (MFunctor t, MonadTrans t) => MMonad (t :: (* -> *) -> * -> *) where
- squash :: (Monad m, MMonad t) => t (t m) a -> t m a
- (>|>) :: (Monad m3, MMonad t) => (forall a. m1 a -> t m2 a) -> (forall b. m2 b -> t m3 b) -> m1 c -> t m3 c
- (<|<) :: (Monad m3, MMonad t) => (forall b. m2 b -> t m3 b) -> (forall a. m1 a -> t m2 a) -> m1 c -> t m3 c
- (=<|) :: (Monad n, MMonad t) => (forall a. m a -> t n a) -> t m b -> t n b
- (|>=) :: (Monad n, MMonad t) => t m b -> (forall a. m a -> t n a) -> t n b
Monad
class Applicative m => Monad (m :: * -> *) where #
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Instances of Monad
should satisfy the following laws:
Furthermore, the Monad
and Applicative
operations should relate as follows:
The above laws imply:
and that pure
and (<*>
) satisfy the applicative functor laws.
The instances of Monad
for lists, Maybe
and IO
defined in the Prelude satisfy these laws.
(>>=) :: m a -> (a -> m b) -> m b infixl 1 #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
Inject a value into the monadic type.
Instances
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 #
Same as >>=
, but with the arguments interchanged.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right Kleisli composition of monads.
join :: Monad m => m (m a) -> m a #
The join
function is the conventional monad join operator. It
is used to remove one level of monadic structure, projecting its
bound argument into the outer level.
whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () #
Like whenJust
, but where the test can be monadic.
Newtypes
newtype Kleisli (m :: * -> *) a b #
Kleisli arrows of a monad.
Kleisli | |
|
Instances
Monad m => Arrow (Kleisli m) | Since: base-2.1 |
MonadPlus m => ArrowZero (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
MonadPlus m => ArrowPlus (Kleisli m) | Since: base-2.1 |
Monad m => ArrowChoice (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
Monad m => ArrowApply (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
MonadFix m => ArrowLoop (Kleisli m) | Beware that for many monads (those for which the Since: base-2.1 |
Defined in Control.Arrow | |
Monad m => Profunctor (Kleisli m) | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Kleisli m b c -> Kleisli m a d # lmap :: (a -> b) -> Kleisli m b c -> Kleisli m a c # rmap :: (b -> c) -> Kleisli m a b -> Kleisli m a c # (#.) :: Coercible c b => (b -> c) -> Kleisli m a b -> Kleisli m a c # (.#) :: Coercible b a => Kleisli m b c -> (a -> b) -> Kleisli m a c # | |
(Monad m, Functor m) => Representable (Kleisli m) | |
Monad m => Choice (Kleisli m) | |
(Monad m, Distributive m) => Mapping (Kleisli m) | |
(Distributive f, Monad f) => Closed (Kleisli f) | |
Defined in Data.Profunctor.Closed | |
Monad m => Strong (Kleisli m) | |
MonadFix m => Costrong (Kleisli m) | |
Monad m => Category (Kleisli m :: * -> * -> *) | Since: base-3.0 |
Bind m => Semigroupoid (Kleisli m :: * -> * -> *) | |
Wrapped (Kleisli m a b) | |
t ~ Kleisli m' a' b' => Rewrapped (Kleisli m a b) t | |
Defined in Control.Lens.Wrapped | |
type Rep (Kleisli m) | |
Defined in Data.Profunctor.Rep | |
type Unwrapped (Kleisli m a b) | |
Defined in Control.Lens.Wrapped |
MMonad
class (MFunctor t, MonadTrans t) => MMonad (t :: (* -> *) -> * -> *) where #
A monad in the category of monads, using lift
from MonadTrans
as the
analog of return
and embed
as the analog of (=<<
):
embed lift = id embed f (lift m) = f m embed g (embed f t) = embed (\m -> embed g (f m)) t
(>|>) :: (Monad m3, MMonad t) => (forall a. m1 a -> t m2 a) -> (forall b. m2 b -> t m3 b) -> m1 c -> t m3 c infixr 2 #
(<|<) :: (Monad m3, MMonad t) => (forall b. m2 b -> t m3 b) -> (forall a. m1 a -> t m2 a) -> m1 c -> t m3 c infixl 2 #