monad-levels-0.1.0.1: Specific levels of monad transformers

Copyright(c) Ivan Lazar Miljenovic
License3-Clause BSD-style
MaintainerIvan.Miljenovic@gmail.com
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Levels.State

Description

Monad environments for stateful computations.

Synopsis

Documentation

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.