ether-0.5.1.0: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Ether.Reader

Contents

Synopsis

MonadReader class

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

Minimal complete definition

(ask | reader), local

Methods

ask :: m r Source #

Retrieves the monad environment.

local :: (r -> r) -> m a -> m a Source #

Executes a computation in a modified environment.

reader :: (r -> a) -> m a Source #

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 # 

Methods

ask :: m (t m) Source #

local :: (t m -> t m) -> m a -> m a Source #

reader :: (t m -> a) -> m a Source #

(Monad (trans m), MonadReader k tag r (TaggedTrans * (Type -> Type) [a] effs trans m)) => MonadReader k tag r (TaggedTrans * (Type -> Type) [a] ((:) a eff effs) trans m) Source # 

Methods

ask :: m (TaggedTrans * (Type -> Type) [a] ((a ': eff) effs) trans m) Source #

local :: (TaggedTrans * (Type -> Type) [a] ((a ': eff) effs) trans m -> TaggedTrans * (Type -> Type) [a] ((a ': eff) effs) trans m) -> m a -> m a Source #

reader :: (TaggedTrans * (Type -> Type) [a] ((a ': eff) effs) trans m -> a) -> m a Source #

(MonadReader k1 tNew r m, (~) ((* -> *) -> * -> *) trans (IdentityT *)) => MonadReader k tOld r (TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m) Source # 

Methods

ask :: m (TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m) Source #

local :: (TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m -> TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m) -> m a -> m a Source #

reader :: (TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m -> a) -> m a Source #

ask :: MonadReader tag r m => m r Source #

Retrieves the monad environment.

local :: MonadReader tag r m => (r -> r) -> m a -> m a Source #

Executes a computation in a modified environment.

reader :: MonadReader tag r m => (r -> a) -> m a Source #

Retrieves a function of the current environment.

asks Source #

Arguments

:: MonadReader tag r m 
=> (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 :: forall tag r a. 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 (TAGGED READER 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 :: forall tag r m a. (r -> m a) -> ReaderT tag r m a Source #

Constructor for computations in the reader monad transformer.

runReaderT :: forall tag r m a. ReaderT tag r m a -> r -> m a Source #

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

The Reader monad (flattened)

runReaders :: forall p a. Readers p a -> p -> a Source #

The ReaderT monad transformer (flattened)

runReadersT :: forall p m a. ReadersT p m a -> p -> m a Source #

MonadReader class (implicit)

local' :: forall r m a. MonadReader' r m => (r -> r) -> m a -> m a Source #

ask' :: forall r m. MonadReader' r m => m r Source #

reader' :: forall r m a. MonadReader' r m => (r -> a) -> m a Source #

asks' :: forall r m a. MonadReader' r m => (r -> a) -> m a Source #

The Reader monad (implicit)

type Reader' r = Reader r r Source #

runReader' :: Reader' r a -> r -> a Source #

The ReaderT monad transformer (implicit)

type ReaderT' r = ReaderT r r Source #

readerT' :: (r -> m a) -> ReaderT' r m a Source #

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

Internal labels

data TAGGED e t Source #

data READER Source #

Encode type-level information for ReaderT.

Instances

Handle * * READER r (ReaderT Type r) Source # 

Methods

handling :: Monad m => (HandleConstraint READER r (ReaderT Type r) p trans m -> r) -> r Source #

type HandleSuper kp * READER r trans Source # 
type HandleSuper kp * READER r trans = ()
type HandleConstraint * * READER r trans m Source # 
type HandleConstraint * * READER r trans m = MonadReader r (trans m)

type family READERS (ts :: HList xs) :: [Type] where ... Source #

Equations

READERS HNil = '[] 
READERS (HCons t ts) = TAGGED READER t ': READERS ts