{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeApplications #-}
module Control.Effect.Reader.Labelled
(
Reader
, ask
, asks
, local
, Algebra
, Effect
, Has
, run
) where
import Control.Effect.Labelled
import qualified Control.Effect.Reader as R
import Control.Effect.Reader.Internal
ask :: forall label r m sig . HasLabelled label (Reader r) sig m => m r
ask :: m r
ask = UnderLabel label (Reader r) m r -> m r
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label UnderLabel label (Reader r) m r
forall r (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (Reader r) sig m =>
m r
R.ask
{-# INLINE ask #-}
asks :: forall label r m a sig . HasLabelled label (Reader r) sig m => (r -> a) -> m a
asks :: (r -> a) -> m a
asks f :: r -> a
f = UnderLabel label (Reader r) m a -> m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((r -> a) -> UnderLabel label (Reader r) m a
forall r (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Reader r) sig m =>
(r -> a) -> m a
R.asks r -> a
f)
{-# INLINE asks #-}
local :: forall label r m a sig . HasLabelled label (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 = UnderLabel label (Reader r) m a -> m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((r -> r)
-> UnderLabel label (Reader r) m a
-> UnderLabel label (Reader r) m a
forall r (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (Reader r) sig m =>
(r -> r) -> m a -> m a
R.local r -> r
f (m a -> UnderLabel label (Reader r) m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
m a -> UnderLabel label sub m a
UnderLabel m a
m))
{-# INLINE local #-}