cognimeta-utils-0.1.2: Utilities for Cognimeta products (such as perdure). API may change often.

Safe HaskellNone

Cgm.Control.Monad.State

Synopsis

Documentation

newtype StateT s m a Source

runStateT and runState do not have the usual types: for now we do not make it too easy to discard the precious Nothing

Constructors

StateT 

Fields

runStateT :: s -> m (a, Maybe s)
 

Instances

(Monad (StateT s m), Monad m) => MonadState s (StateT s m) 
MonadTrans (StateT s) 
Monad m => Monad (StateT s m) 
Functor m => Functor (StateT s m) 
(Functor (StateT s m), Functor m, Monad m) => Applicative (StateT s m) 
(Monad (StateT s m), MonadIO m) => MonadIO (StateT s m) 

mState :: (s -> (a, Maybe s)) -> State s aSource

runState :: State s a -> s -> (a, Maybe s)Source

focus :: Monad m => Lens t s -> StateT s m a -> StateT t m aSource

viewState :: Monad m => (s -> t, t -> s) -> StateT t m a -> StateT s m aSource

functions st and ts should form a bijection since a StateT t with no changes will become a StateT s with no changes, no matter what st and ts are

partialState :: Monad m => m a -> (s -> Maybe t, t -> s) -> StateT t m a -> StateT s m aSource

partialStateE :: Monad m => m a -> (s -> Maybe t, t -> s) -> StateT t m b -> StateT s m (Either a b)Source

eitherState :: Monad m => StateT s m a -> StateT t m a -> StateT (Either s t) m aSource

maybeState :: Monad m => m a -> StateT s m a -> StateT (Maybe s) m aSource

toStandardState :: Monad m => StateT s m a -> StateT s m aSource

mapStateT :: (m (a, Maybe s) -> n (b, Maybe s)) -> StateT s m a -> StateT s n bSource

pairStateT :: Functor m => StateT s (StateT t m) a -> StateT (s, t) m aSource