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
- class (HFunctor sig, Monad m) => Carrier sig m | m -> sig
- class Member (sub :: (* -> *) -> * -> *) sup
- run :: PureC a -> a
Reader effect
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)
Reader carrier
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 # | |
MonadFix m => MonadFix (ReaderC s m) Source # | |
Defined in Control.Effect.Reader | |
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 # | |
Re-exports
class (HFunctor sig, Monad m) => Carrier sig m | m -> sig Source #
The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the eff
method.