{-# LANGUAGE TemplateHaskell #-}
module Polysemy.EndState
(
EndState(..)
, getEndState
, runEndState
, runEndAtomicState
) where
import Polysemy
import Polysemy.Fixpoint
import Polysemy.Reader
import Polysemy.Reader.More
import Polysemy.State
import Polysemy.AtomicState
data EndState s m a where
GetEndState :: EndState s m s
makeSem ''EndState
runEndState :: forall s r a
. (Member (State s) r, Member Fixpoint r)
=> Sem (EndState s ': r) a
-> Sem r a
runEndState =
runReaderFixSem (get @s)
. reinterpret (\GetEndState -> ask)
runEndAtomicState
:: forall s r a
. (Member (AtomicState s) r, Member Fixpoint r)
=> Sem (EndState s ': r) a
-> Sem r a
runEndAtomicState =
runReaderFixSem (atomicGet @s)
. reinterpret (\GetEndState -> ask)