Copyright | (C) 2012-2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
This module provides the Bound
class, for performing substitution into
things that are not necessarily full monad transformers.
Documentation
Instances of Bound
generate left modules over monads.
This means they should satisfy the following laws:
m>>>=
return
≡ m m>>>=
(λ x → k x>>=
h) ≡ (m>>>=
k)>>>=
h
This guarantees that a typical Monad instance for an expression type where Bound instances appear will satisfy the Monad laws (see doc/BoundLaws.hs).
If instances of Bound
are monad transformers, then m
implies the above laws, and is in fact the default definition.>>>=
f ≡ m >>=
lift
.
f
This is useful for types like expression lists, case alternatives, schemas, etc. that may not be expressions in their own right, but often contain expressions.
Note: Free
isn't "really" a monad transformer, even if
the kind matches. Therefore there isn't
instance.Bound
Free
Nothing
(>>>=) :: Monad f => t f a -> (a -> f c) -> t f c infixl 1 Source #
Perform substitution
If t
is an instance of MonadTrans
and you are compiling on GHC >= 7.4, then this
gets the default definition:
m>>>=
f = m>>=
lift
.
f
(>>>=) :: (MonadTrans t, Monad f, Monad (t f)) => t f a -> (a -> f c) -> t f c infixl 1 Source #
Instances
Bound ListT Source # | |
Bound MaybeT Source # | |
Bound (IdentityT :: (Type -> Type) -> Type -> Type) Source # | |
Error e => Bound (ErrorT e) Source # | |
Bound (StateT s) Source # | |
Monoid w => Bound (WriterT w) Source # | |
Bound (Scope b) Source # | |
Bound (Scope b) Source # | |
Bound (ContT c) Source # | |
Bound (ReaderT r :: (Type -> Type) -> Type -> Type) Source # | |
Monoid w => Bound (RWST r w s) Source # | |