{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Control.Effect.State.Labelled
(
State
, get
, gets
, put
, modify
, modifyLazy
, state
, Algebra
, Effect
, Has
, run
) where
import Control.Effect.Labelled
import qualified Control.Effect.State as S
import Control.Effect.State.Internal
get :: forall label s m sig . HasLabelled label (State s) sig m => m s
get :: m s
get = UnderLabel label (State s) m s -> m s
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label UnderLabel label (State s) m s
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (State s) sig m =>
m s
S.get
{-# INLINEABLE get #-}
gets :: forall label s m a sig . HasLabelled label (State s) sig m => (s -> a) -> m a
gets :: (s -> a) -> m a
gets f :: s -> a
f = UnderLabel label (State s) m a -> m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((s -> a) -> UnderLabel label (State s) m a
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (State s) sig m =>
(s -> a) -> m a
S.gets s -> a
f)
{-# INLINEABLE gets #-}
put :: forall label s m sig . HasLabelled label (State s) sig m => s -> m ()
put :: s -> m ()
put s :: s
s = UnderLabel label (State s) m () -> m ()
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label (s -> UnderLabel label (State s) m ()
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (State s) sig m =>
s -> m ()
S.put s
s)
{-# INLINEABLE put #-}
modify :: forall label s m sig . HasLabelled label (State s) sig m => (s -> s) -> m ()
modify :: (s -> s) -> m ()
modify f :: s -> s
f = UnderLabel label (State s) m () -> m ()
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((s -> s) -> UnderLabel label (State s) m ()
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (State s) sig m =>
(s -> s) -> m ()
S.modify s -> s
f)
{-# INLINEABLE modify #-}
modifyLazy :: forall label s m sig . HasLabelled label (State s) sig m => (s -> s) -> m ()
modifyLazy :: (s -> s) -> m ()
modifyLazy f :: s -> s
f = UnderLabel label (State s) m () -> m ()
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((s -> s) -> UnderLabel label (State s) m ()
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *).
Has (State s) sig m =>
(s -> s) -> m ()
S.modifyLazy s -> s
f)
{-# INLINEABLE modifyLazy #-}
state :: forall label s m a sig . HasLabelled label (State s) sig m => (s -> (s, a)) -> m a
state :: (s -> (s, a)) -> m a
state f :: s -> (s, a)
f = UnderLabel label (State s) m a -> m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
runUnderLabel @label ((s -> (s, a)) -> UnderLabel label (State s) m a
forall s (sig :: (* -> *) -> * -> *) (m :: * -> *) a.
Has (State s) sig m =>
(s -> (s, a)) -> m a
S.state s -> (s, a)
f)
{-# INLINEABLE state #-}