fused-effects-0.3.0.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 => Carrier (Reader r :+: sig) (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

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

ret :: 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) => (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 #

Constructors

ReaderC 

Fields

Instances
MonadTrans (ReaderC r) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

lift :: Monad m => m a -> ReaderC r m a #

Monad m => Monad (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

(>>=) :: ReaderC r m a -> (a -> ReaderC r m b) -> ReaderC r m b #

(>>) :: ReaderC r m a -> ReaderC r m b -> ReaderC r m b #

return :: a -> ReaderC r m a #

fail :: String -> ReaderC r m a #

Functor m => Functor (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

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

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

MonadFail m => MonadFail (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

fail :: String -> ReaderC r m a #

Applicative m => Applicative (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

pure :: a -> ReaderC r m a #

(<*>) :: ReaderC r m (a -> b) -> ReaderC r m a -> ReaderC r m b #

liftA2 :: (a -> b -> c) -> ReaderC r m a -> ReaderC r m b -> ReaderC r m c #

(*>) :: ReaderC r m a -> ReaderC r m b -> ReaderC r m b #

(<*) :: ReaderC r m a -> ReaderC r m b -> ReaderC r m a #

MonadIO m => MonadIO (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

liftIO :: IO a -> ReaderC r m a #

Alternative m => Alternative (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

empty :: ReaderC r m a #

(<|>) :: ReaderC r m a -> ReaderC r m a -> ReaderC r m a #

some :: ReaderC r m a -> ReaderC r m [a] #

many :: ReaderC r m a -> ReaderC r m [a] #

(Alternative m, Monad m) => MonadPlus (ReaderC r m) Source # 
Instance details

Defined in Control.Effect.Reader

Methods

mzero :: ReaderC r m a #

mplus :: ReaderC r m a -> ReaderC r m a -> ReaderC r m a #

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

Defined in Control.Effect.Reader

Methods

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

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