module Control.Effect.Reader
(
Reader(..)
, ask
, asks
, local
, Algebra
, Has
, run
) where
import Control.Algebra
import Control.Effect.Reader.Internal (Reader(..))
ask :: Has (Reader r) sig m => m r
ask :: forall r (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (Reader r) sig m =>
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 Reader r m r
forall r (m :: * -> *). Reader r m r
Ask
{-# INLINE ask #-}
asks :: Has (Reader r) sig m => (r -> a) -> m a
asks :: forall r (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Reader r) sig m =>
(r -> a) -> m a
asks = ((r -> a) -> m r -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` m r
forall r (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (Reader r) sig m =>
m r
ask)
{-# INLINE asks #-}
local :: Has (Reader r) sig m => (r -> r) -> m a -> m a
local :: forall r (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Reader r) sig m =>
(r -> r) -> m a -> m a
local r -> r
f 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 -> Reader r m a
forall r (m :: * -> *) a. (r -> r) -> m a -> Reader r m a
Local r -> r
f m a
m)
{-# INLINE local #-}