monad-levels- Specific levels of monad transformers

Copyright(c) Ivan Lazar Miljenovic
License3-Clause BSD-style
Safe HaskellNone



Monad environments for stateful computations.



state :: forall m s a. HasState s m => (s -> (a, s)) -> m a Source

Embed a simple state action into the monad stack.

get :: HasState s m => m s Source

Obtain the state environment.

gets :: HasState s m => (s -> a) -> m a Source

Apply a function to the stateful environment. Equivalent to fmap f get.

put :: HasState s m => s -> m () Source

Replace the stateful environment.

modify :: HasState s m => (s -> s) -> m () Source

Map the old state to a new state, and discard the old one. Equivalent to gets f >>= put.

modify' :: HasState s m => (s -> s) -> m () Source

A variant of modify in which the computation is strict in the new state.

type HasState s m = SatisfyConstraint (IsState s) m Source

A monad stack containing a stateful environment of type s.

class MonadTower m => IsState s m Source

The minimal definition needed for a monad providing a stateful environment.