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