ether-0.4.0.2: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Trans.Ether.Reader

Contents

Description

Synopsis

The Reader monad

type Reader tag r = ReaderT tag r Identity Source

The parameterizable reader monad.

Computations are functions of a shared environment.

The return function ignores the environment, while >>= passes the inherited environment to both subcomputations.

reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a Source

Constructor for computations in the reader monad (the inverse of runReader).

runReader :: proxy tag -> Reader tag r a -> r -> a Source

Runs a ReaderT with the given environment and returns the final value.

The ReaderT monad transformer

type ReaderT tag r = TaggedTrans tag (ReaderT r) Source

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.

readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a Source

Constructor for computations in the reader monad transformer.

runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a Source

Runs a ReaderT with the given environment and returns the final value.

Reader operations

ask :: Monad m => proxy tag -> ReaderT tag r m r Source

Fetch the value of the environment.

local Source

Arguments

:: proxy tag 
-> (r -> r)

The function to modify the environment.

-> ReaderT tag r m a

Computation to run in the modified environment.

-> ReaderT tag r m a 

Execute a computation in a modified environment (a specialization of withReaderT).