HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduletransformers-0.6.3.0Haskell2010

Control.Monad.Trans.Reader

Declaration of the ReaderT monad transformer, which adds a static environment to a given monad.

If the computation is to modify the stored information, use Control.Monad.Trans.State instead.

Contents
  1. The Reader monad
  2. The ReaderT monad transformer
  3. Reader operations
  4. Lifting other operations
Synopsis

The Reader monad

valuerunReader
  1. :: Reader r a

    A Reader to run.

  2. -> r

    An initial environment.

  3. -> a

Runs a Reader and extracts the final value from it. (The inverse of reader.)

The ReaderT monad transformer

newtypenewtype ReaderT r (m :: Type -> Type) a

The reader monad transformer, which adds a read-only environment to the given monad.

The return function ignores the environment, while m >>= k passes the inherited environment to both subcomputations:

image: images/bind-ReaderT.svg

ReaderT r m is strict if and only if m is.

Constructors

Instances15Generic1, MonadTrans, Monad, Functor, MonadFix, MonadFail, …

Reader operations

valueasks
  1. :: Monad m
  2. => (r -> a)

    The selector function to apply to the environment.

  3. -> ReaderT r m a

Retrieve a function of the current environment.

Lifting other operations