polysemy-zoo-0.8.1.0: Experimental, user-contributed effects and interpreters for polysemy
Safe HaskellNone
LanguageHaskell2010

Polysemy.RevState

Synopsis

Effect

newtype RevState s m a where Source #

A State effect for threading state backwards instead of forwards through a computation.

Constructors

RevState :: (s -> (s, a)) -> RevState s m a 

Actions

revState :: forall s a r. Member (RevState s) r => (s -> (s, a)) -> Sem r a Source #

Gets the state as sent from the next call to revState / revPut / revModify, use it, and send a new state into the past.

revGet :: forall s r. Member (RevState s) r => Sem r s Source #

Gets the state as sent from the next call to revState / revPut / revModify.

revPut :: forall s r. Member (RevState s) r => s -> Sem r () Source #

Sends a new state into the past.

revModify :: forall s r. Member (RevState s) r => (s -> s) -> Sem r () Source #

Gets the state as sent from the next call to revState / revModify / revPut, modify it, and return it into the past.

Interpretations

runRevState :: Member Fixpoint r => s -> Sem (RevState s ': r) a -> Sem r (s, a) Source #

Run a RevState effect with local state that is propagated backwards through the computation, from last action to first.

runLazyRevState :: Member Fixpoint r => s -> Sem (RevState s ': r) a -> Sem r (s, a) Source #

Run a RevState effect with local state that is lazily propagated backwards through the computation, from last action to first.