ether-0.4.0.1: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Ether.Reader

Contents

Description

Synopsis

MonadReader class

class Monad m => MonadReader tag r m | m tag -> r where Source

Minimal complete definition

(ask | reader), local

Methods

ask :: proxy tag -> m r Source

Retrieves the monad environment.

local Source

Arguments

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

The function to modify the environment.

-> m a

Reader to run in the modified environment.

-> m a 

Executes a computation in a modified environment.

reader Source

Arguments

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

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

Instances

(LiftLocal t, Monad (t m), MonadReader k tag r m) => MonadReader k tag r (t m) Source 
(Monad m, (~) * r r') => MonadReader k tag r (ReaderT k tag r' m) Source 

asks Source

Arguments

:: MonadReader tag r m 
=> proxy tag 
-> (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

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.

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.