foundation-0.0.3: Alternative prelude with batteries and no dependencies

Safe HaskellNone
LanguageHaskell2010

Foundation.Monad

Synopsis

Documentation

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

liftIO

Methods

liftIO :: IO a -> m a #

Lift a computation from the IO monad.

Instances

MonadIO IO 

Methods

liftIO :: IO a -> IO a #

MonadIO m => MonadIO (ReaderT r m) # 

Methods

liftIO :: IO a -> ReaderT r m a #

(Functor m, MonadIO m) => MonadIO (StateT s m) # 

Methods

liftIO :: IO a -> StateT s m a #

class Monad m => MonadFailure m where Source #

Monad that can represent failure

Similar to MonadFail but with a parametrized Failure linked to the Monad

Minimal complete definition

mFail

Associated Types

type Failure m Source #

The associated type with the MonadFailure, representing what failure can be encoded in this monad

Methods

mFail :: Failure m -> m () Source #

Raise a Failure through a monad.

Instances

MonadFailure Maybe Source # 

Associated Types

type Failure (Maybe :: * -> *) :: * Source #

Methods

mFail :: Failure Maybe -> Maybe () Source #

MonadFailure (Either a) Source # 

Associated Types

type Failure (Either a :: * -> *) :: * Source #

Methods

mFail :: Failure (Either a) -> Either a () Source #

MonadFailure m => MonadFailure (ReaderT r m) Source # 

Associated Types

type Failure (ReaderT r m :: * -> *) :: * Source #

Methods

mFail :: Failure (ReaderT r m) -> ReaderT r m () Source #

(Functor m, MonadFailure m) => MonadFailure (StateT s m) Source # 

Associated Types

type Failure (StateT s m :: * -> *) :: * Source #

Methods

mFail :: Failure (StateT s m) -> StateT s m () Source #

class Monad m => MonadThrow m where Source #

Monad that can throw exception

Minimal complete definition

throw

Methods

throw :: Exception e => e -> m a Source #

Throw immediatity an exception. Only a MonadCatch monad will be able to catch the exception using catch

Instances

MonadThrow IO Source # 

Methods

throw :: Exception e => e -> IO a Source #

MonadThrow m => MonadThrow (ReaderT r m) Source # 

Methods

throw :: Exception e => e -> ReaderT r m a Source #

(Functor m, MonadThrow m) => MonadThrow (StateT s m) Source # 

Methods

throw :: Exception e => e -> StateT s m a Source #

class MonadThrow m => MonadCatch m where Source #

Monad that can catch exception

Minimal complete definition

catch

Methods

catch :: Exception e => m a -> (e -> m a) -> m a Source #

Instances

MonadCatch IO Source # 

Methods

catch :: Exception e => IO a -> (e -> IO a) -> IO a Source #

MonadCatch m => MonadCatch (ReaderT r m) Source # 

Methods

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a Source #

(Functor m, MonadCatch m) => MonadCatch (StateT s m) Source # 

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a Source #

class MonadTrans trans where Source #

Basic Transformer class

Minimal complete definition

lift

Methods

lift :: Monad m => m a -> trans m a Source #

Lift a computation from an inner monad to the current transformer monad

Instances

MonadTrans (ReaderT r) Source # 

Methods

lift :: Monad m => m a -> ReaderT r m a Source #

MonadTrans (StateT s) Source # 

Methods

lift :: Monad m => m a -> StateT s m a Source #