| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Bricks.Internal.Monad
- class Monad m => MonadIO (m :: * -> *) where
- class Monad m => MonadError e (m :: * -> *) | m -> e where
- newtype ExceptT e (m :: * -> *) a :: * -> (* -> *) -> * -> * = ExceptT (m (Either e a))
- runExceptT :: ExceptT e m a -> m (Either e a)
- newtype ReaderT k r (m :: k -> *) (a :: k) :: forall k. * -> (k -> *) -> k -> * = ReaderT {
- runReaderT :: r -> m a
IO
class Monad m => MonadIO (m :: * -> *) where #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Minimal complete definition
Instances
| MonadIO IO | Since: 4.9.0.0 |
| MonadIO Eval # | |
| MonadIO m => MonadIO (ListT m) | |
| MonadIO m => MonadIO (MaybeT m) | |
| (Error e, MonadIO m) => MonadIO (ErrorT e m) | |
| MonadIO m => MonadIO (ExceptT e m) | |
| MonadIO m => MonadIO (StateT s m) | |
| MonadIO m => MonadIO (StateT s m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| (Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
| MonadIO m => MonadIO (IdentityT * m) | |
| MonadIO m => MonadIO (ReaderT * r m) | |
| MonadIO m => MonadIO (ParsecT s u m) | |
| (Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
| (Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
Error
class Monad m => MonadError e (m :: * -> *) | m -> e where #
The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information and
the monad type constructor.
It is common to use as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the Either StringMonadError class.
You can also define your own error type and/or use a monad type constructor
other than or Either String.
In these cases you will have to explicitly define instances of the Either IOErrorError
and/or MonadError classes.
Minimal complete definition
Methods
throwError :: e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: m a -> (e -> m a) -> m a #
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handlerwhere the action functions can call throwError.
Note that handler and the do-block must have the same return type.
Instances
| MonadError IOException IO | |
| MonadError Bottom Eval # | |
| MonadError e m => MonadError e (MaybeT m) | |
| MonadError e m => MonadError e (ListT m) | |
| MonadError e (Either e) | |
| (Monoid w, MonadError e m) => MonadError e (WriterT w m) | |
| (Monoid w, MonadError e m) => MonadError e (WriterT w m) | |
| MonadError e m => MonadError e (StateT s m) | |
| MonadError e m => MonadError e (StateT s m) | |
| MonadError e m => MonadError e (IdentityT * m) | |
| Monad m => MonadError e (ExceptT e m) | |
| (Monad m, Error e) => MonadError e (ErrorT e m) | |
| MonadError e m => MonadError e (ReaderT * r m) | |
| MonadError e m => MonadError e (ParsecT s u m) | |
| (Monoid w, MonadError e m) => MonadError e (RWST r w s m) | |
| (Monoid w, MonadError e m) => MonadError e (RWST r w s m) | |
newtype ExceptT e (m :: * -> *) a :: * -> (* -> *) -> * -> * #
A monad transformer that adds exceptions to other monads.
ExceptT constructs a monad parameterized over two things:
- e - The exception type.
- m - The inner monad.
The return function yields a computation that produces the given
value, while >>= sequences two subcomputations, exiting on the
first exception.
Instances
| Monad m => MonadError e (ExceptT e m) | |
| MonadTrans (ExceptT e) | |
| Monad m => Monad (ExceptT e m) | |
| Functor m => Functor (ExceptT e m) | |
| MonadFix m => MonadFix (ExceptT e m) | |
| MonadFail m => MonadFail (ExceptT e m) | |
| (Functor m, Monad m) => Applicative (ExceptT e m) | |
| Foldable f => Foldable (ExceptT e f) | |
| Traversable f => Traversable (ExceptT e f) | |
| (Eq e, Eq1 m) => Eq1 (ExceptT e m) | |
| (Ord e, Ord1 m) => Ord1 (ExceptT e m) | |
| (Read e, Read1 m) => Read1 (ExceptT e m) | |
| (Show e, Show1 m) => Show1 (ExceptT e m) | |
| MonadZip m => MonadZip (ExceptT e m) | |
| MonadIO m => MonadIO (ExceptT e m) | |
| (Functor m, Monad m, Monoid e) => Alternative (ExceptT e m) | |
| (Monad m, Monoid e) => MonadPlus (ExceptT e m) | |
| (Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a) | |
| (Ord e, Ord1 m, Ord a) => Ord (ExceptT e m a) | |
| (Read e, Read1 m, Read a) => Read (ExceptT e m a) | |
| (Show e, Show1 m, Show a) => Show (ExceptT e m a) | |
runExceptT :: ExceptT e m a -> m (Either e a) #
The inverse of ExceptT.
Reader
newtype ReaderT k r (m :: k -> *) (a :: k) :: forall k. * -> (k -> *) -> k -> * #
The reader monad transformer, which adds a read-only environment to the given monad.
The return function ignores the environment, while >>= passes
the inherited environment to both subcomputations.
Constructors
| ReaderT | |
Fields
| |
Instances
| MonadError e m => MonadError e (ReaderT * r m) | |
| MonadTrans (ReaderT * r) | |
| Monad m => Monad (ReaderT * r m) | |
| Functor m => Functor (ReaderT * r m) | |
| MonadFix m => MonadFix (ReaderT * r m) | |
| MonadFail m => MonadFail (ReaderT * r m) | |
| Applicative m => Applicative (ReaderT * r m) | |
| MonadZip m => MonadZip (ReaderT * r m) | |
| MonadIO m => MonadIO (ReaderT * r m) | |
| Alternative m => Alternative (ReaderT * r m) | |
| MonadPlus m => MonadPlus (ReaderT * r m) | |