{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Control.Effect.State.Labelled
(
State
, get
, gets
, put
, modify
, modifyLazy
, state
, Algebra
, Has
, HasLabelled
, 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 :: forall {k} (label :: k) s (m :: * -> *)
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
m s
get = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
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 :: forall {k} (label :: k) s (m :: * -> *) a
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
(s -> a) -> m a
gets s -> a
f = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub 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 :: forall {k} (label :: k) s (m :: * -> *)
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
s -> m ()
put s
s = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
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 :: forall {k} (label :: k) s (m :: * -> *)
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
(s -> s) -> m ()
modify s -> s
f = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
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 :: forall {k} (label :: k) s (m :: * -> *)
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
(s -> s) -> m ()
modifyLazy s -> s
f = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub m a -> m a
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 :: forall {k} (label :: k) s (m :: * -> *) a
(sig :: (* -> *) -> * -> *).
HasLabelled label (State s) sig m =>
(s -> (s, a)) -> m a
state s -> (s, a)
f = forall (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
UnderLabel label sub 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 #-}