monad-levels-0.1.0.0: 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.Lazy

Description

Lazy 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.

newtype StateT s m a :: * -> (* -> *) -> * -> *

A state transformer monad parameterized by:

  • s - The state.
  • m - The inner monad.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

Constructors

StateT 

Fields

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

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.