Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Reader tag r = ReaderT tag r Identity
- reader :: Monad m => proxy tag -> (r -> a) -> ReaderT tag r m a
- runReader :: proxy tag -> Reader tag r a -> r -> a
- data ReaderT tag r m a
- readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
- runReaderT :: proxy tag -> ReaderT tag r m a -> r -> m a
- mapReaderT :: proxy tag -> (m a -> n b) -> ReaderT tag r m a -> ReaderT tag r n b
- withReaderT :: proxy tag -> (r' -> r) -> ReaderT tag r m a -> ReaderT tag r' m a
- ask :: Monad m => proxy tag -> ReaderT tag r m r
- local :: proxy tag -> (r -> r) -> ReaderT tag r m a -> ReaderT tag r m a
- liftCatch :: proxy tag -> Catch e m a -> Catch e (ReaderT tag r m) a
- liftCallCC :: proxy tag -> CallCC m a b -> CallCC (ReaderT tag r m) a b
The Reader monad
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 vinal value.
The ReaderT monad transformer
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 vinal value.
mapReaderT :: proxy tag -> (m a -> n b) -> ReaderT tag r m a -> ReaderT tag r n b Source
Transform the computation inside a ReaderT
.
runReaderT
tag (mapReaderT
tag f m) = f .runReaderT
tag m
:: 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 more general version of local
).
runReaderT
tag (withReaderT
tag f m) =runReaderT
tag m . f
Reader operations
:: 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
).
runReaderT
tag (local
tag f m) =runReaderT
tag m . f
Lifting other operations
liftCatch :: proxy tag -> Catch e m a -> Catch e (ReaderT tag r m) a Source
Lift a catchE
operation to the new monad.
liftCallCC :: proxy tag -> CallCC m a b -> CallCC (ReaderT tag r m) a b Source
Lift a callCC
operation to the new monad.