foundation-0.0.30: Alternative prelude with batteries and no dependencies

Safe Haskell | None
Language | Haskell2010

Foundation.Monad.Reader

Contents

- MonadReader
- ReaderT

Description

The Reader monad transformer.

This is useful to keep a non-modifiable value in a context

Synopsis

- class Monad m => MonadReader (m :: Type -> Type) where
  - type ReaderContext (m :: Type -> Type)
  - ask :: m (ReaderContext m)
- data ReaderT r (m :: Type -> Type) a
- runReaderT :: ReaderT r m a -> r -> m a

# MonadReader

class Monad m => MonadReader (m :: Type -> Type) where #

Associated Types

type ReaderContext (m :: Type -> Type) #

Methods

ask :: m (ReaderContext m) #

#### Instances

Instances details

MonadReader m => MonadReader (ExceptT e m) # |
Instance details Defined in Foundation.Monad.Except Associated Types
type ReaderContext (ExceptT e m) |
Instance details Defined in Foundation.Monad.Except type ReaderContext (ExceptT e m) = ReaderContext m
Methods ask :: ExceptT e m (ReaderContext (ExceptT e m)) #
Monad m => MonadReader (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Associated Types
type ReaderContext (ReaderT r m) |
Instance details Defined in Foundation.Monad.Reader type ReaderContext (ReaderT r m) = r
Methods ask :: ReaderT r m (ReaderContext (ReaderT r m)) #

# ReaderT

data ReaderT r (m :: Type -> Type) a #

Reader Transformer

#### Instances

Instances details

MonadTrans (ReaderT r) # |
Instance details Defined in Foundation.Monad.Reader Methods lift :: Monad m => m a -> ReaderT r m a #
MonadIO m => MonadIO (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods liftIO :: IO a -> ReaderT r m a #
MonadFailure m => MonadFailure (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Associated Types
type Failure (ReaderT r m) |
Instance details Defined in Foundation.Monad.Reader type Failure (ReaderT r m) = Failure m
Methods mFail :: Failure (ReaderT r m) -> ReaderT r m () #
MonadBracket m => MonadBracket (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods generalBracket :: ReaderT r m a -> (a -> b -> ReaderT r m ignored1) -> (a -> SomeException -> ReaderT r m ignored2) -> (a -> ReaderT r m b) -> ReaderT r m b #
MonadCatch m => MonadCatch (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #
MonadThrow m => MonadThrow (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods throw :: Exception e => e -> ReaderT r m a #
Monad m => MonadReader (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Associated Types
type ReaderContext (ReaderT r m) |
Instance details Defined in Foundation.Monad.Reader type ReaderContext (ReaderT r m) = r
Methods ask :: ReaderT r m (ReaderContext (ReaderT r m)) #
Applicative m => Applicative (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods pure :: a -> ReaderT r m a # (<*>) :: ReaderT r m (a -> b) -> ReaderT r m a -> ReaderT r m b # liftA2 :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c # (*>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b # (<*) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m a #
Functor m => Functor (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods fmap :: (a -> b) -> ReaderT r m a -> ReaderT r m b # (<$) :: a -> ReaderT r m b -> ReaderT r m a #
Monad m => Monad (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader Methods (>>=) :: ReaderT r m a -> (a -> ReaderT r m b) -> ReaderT r m b # (>>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b # return :: a -> ReaderT r m a #
(Monad m, MonadFix m) => MonadFix (ReaderT s m) # |
Instance details Defined in Foundation.Monad.Reader Methods mfix :: (a -> ReaderT s m a) -> ReaderT s m a #
type Failure (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader type Failure (ReaderT r m) = Failure m
type ReaderContext (ReaderT r m) # |
Instance details Defined in Foundation.Monad.Reader type ReaderContext (ReaderT r m) = r

runReaderT :: ReaderT r m a -> r -> m a #