Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Reader r m k
- ask :: (Member (Reader r) sig, Carrier sig m) => m r
- asks :: (Member (Reader r) sig, Carrier sig m) => (r -> a) -> m a
- local :: (Member (Reader r) sig, Carrier sig m) => (r -> r) -> m a -> m a
- runReader :: r -> ReaderC r m a -> m a
- newtype ReaderC r m a = ReaderC {
- runReaderC :: r -> m a
Documentation
ask :: (Member (Reader r) sig, Carrier sig m) => m r Source #
Retrieve the environment value.
run (runReader a ask) == a
asks :: (Member (Reader r) sig, Carrier sig m) => (r -> a) -> m a Source #
Project a function out of the current environment value.
snd (run (runReader a (asks (applyFun f)))) == applyFun f a
local :: (Member (Reader r) sig, Carrier sig m) => (r -> r) -> m a -> m a Source #
Run a computation with an environment value locally modified by the passed function.
run (runReader a (local (applyFun f) ask)) == applyFun f a
run (runReader a ((,,) <$> ask <*> local (applyFun f) ask <*> ask)) == (a, applyFun f a, a)
runReader :: r -> ReaderC r m a -> m a Source #
Run a Reader
effect with the passed environment value.
run (runReader a (pure b)) == b
newtype ReaderC r m a Source #
ReaderC | |
|
Instances
MonadTrans (ReaderC r) Source # | |
Defined in Control.Effect.Reader | |
Monad m => Monad (ReaderC r m) Source # | |
Functor m => Functor (ReaderC r m) Source # | |
MonadFail m => MonadFail (ReaderC r m) Source # | |
Defined in Control.Effect.Reader | |
Applicative m => Applicative (ReaderC r m) Source # | |
Defined in Control.Effect.Reader | |
MonadIO m => MonadIO (ReaderC r m) Source # | |
Defined in Control.Effect.Reader | |
Alternative m => Alternative (ReaderC r m) Source # | |
(Alternative m, Monad m) => MonadPlus (ReaderC r m) Source # | |
MonadUnliftIO m => MonadUnliftIO (ReaderC r m) Source # | |
Defined in Control.Effect.Reader askUnliftIO :: ReaderC r m (UnliftIO (ReaderC r m)) withRunInIO :: ((forall a. ReaderC r m a -> IO a) -> IO b) -> ReaderC r m b | |
Carrier sig m => Carrier (Reader r :+: sig) (ReaderC r m) Source # | |