fused-effects-0.1.2.0: A fast, flexible, fused effect system.

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Reader

Synopsis

Documentation

data Reader r m k Source #

Constructors

Ask (r -> k) 
Local (r -> r) (m b) (b -> k) 
Instances
Effect (Reader r) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

handle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> Reader r m (m a) -> Reader r n (n (f a)) Source #

HFunctor (Reader r) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

fmap' :: (a -> b) -> Reader r m a -> Reader r m b Source #

hmap :: (forall x. m x -> n x) -> Reader r m a -> Reader r n a Source #

Functor (Reader r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

fmap :: (a -> b) -> Reader r m a -> Reader r m b #

(<$) :: a -> Reader r m b -> Reader r m a #

(Carrier sig m, Monad m) => Carrier (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

ret :: a -> ReaderC r m a Source #

eff :: (Reader r :+: sig) (ReaderC r m) (ReaderC r m a) -> ReaderC r m a Source #

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, Functor 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 :: (Carrier sig m, Monad m) => r -> Eff (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 #

Constructors

ReaderC 

Fields

Instances
(Carrier sig m, Monad m) => Carrier (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

ret :: a -> ReaderC r m a Source #

eff :: (Reader r :+: sig) (ReaderC r m) (ReaderC r m a) -> ReaderC r m a Source #