Module

WAGS.Control.MemoizedState

Package
purescript-wags
Repository
mikesol/purescript-wags

#MemoizedStateT Source

newtype MemoizedStateT (proof :: Type) s m a

MemoizedStateT combines the StateT monad and the Env comonad. It is similar to StateT s (m (Env a)). It is useful when a state combines elements that are known and unknown. The proof term allows producers to lock an initial state in place.

Constructors

Instances

#MemoizedState Source

type MemoizedState (proof :: Type) s a = MemoizedStateT proof s Identity a

#runMemoizedStateT' Source

runMemoizedStateT' :: forall proof s m a. Monad m => MemoizedStateT proof s m a -> proof -> (s -> s) -> s -> m (Tuple a s)

Run a MemoizedStateT'. The proof term should be the same one used to create the initial MemoizedStateT. s -> s is a transformer of the initial state provided when makeMemoizedStateT was called. The s value is discarded unless no initial state was provided via a proof term.

#runMemoizedState' Source

runMemoizedState' :: forall proof s a. MemoizedState proof s a -> proof -> (s -> s) -> s -> Tuple a s

runMemoizedStateT' for the Identity monad.

#runMemoizedStateT Source

runMemoizedStateT :: forall proof s m a. Monad m => MemoizedStateT proof s m a -> proof -> s -> m (Tuple a s)

runMemoizedStateT' without a transformer for the initial state.

#runMemoizedState Source

runMemoizedState :: forall proof s a. MemoizedState proof s a -> proof -> s -> Tuple a s

runMemoizedStateT' without a transformer for the initial state & for the Identity monad.

#makeMemoizedStateT Source

makeMemoizedStateT :: forall proof s m a. Monad m => proof -> s -> a -> MemoizedStateT proof s m a

Given proof, create a MemoizedStateT with an initial state.

#makeMemoizedState Source

makeMemoizedState :: forall proof s a. proof -> s -> a -> MemoizedState proof s a

Given proof, create a MemoizedState with an initial state.