module Control.Effect.Reader
(
Reader(..)
, ask
, asks
, local
, Algebra
, Effect
, Has
, run
) where
import Control.Algebra
import Control.Effect.Reader.Internal (Reader(..))
ask :: Has (Reader r) sig m => m r
ask :: m r
ask = Reader r m r -> m r
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send ((r -> m r) -> Reader r m r
forall r (m :: * -> *) k. (r -> m k) -> Reader r m k
Ask r -> m r
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
asks :: Has (Reader r) sig m => (r -> a) -> m a
asks :: (r -> a) -> m a
asks f :: r -> a
f = Reader r m a -> m a
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send ((r -> m a) -> Reader r m a
forall r (m :: * -> *) k. (r -> m k) -> Reader r m k
Ask (a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> m a) -> (r -> a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> a
f))
local :: Has (Reader r) sig m => (r -> r) -> m a -> m a
local :: (r -> r) -> m a -> m a
local f :: r -> r
f m :: m a
m = Reader r m a -> m a
forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send ((r -> r) -> m a -> (a -> m a) -> Reader r m a
forall r (m :: * -> *) k b.
(r -> r) -> m b -> (b -> m k) -> Reader r m k
Local r -> r
f m a
m a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)