contstuff-1.2.3: Fast, easy to use CPS-based monad transformers

Stabilityexperimental
MaintainerErtugrul Soeylemez <es@ertes.de>

Control.ContStuff.Monads

Contents

Description

This module implements the non-transformer variants of the monad transformers found in Control.ContStuff.Trans.

Synopsis

Monads

Choice

type Choice r i a = ChoiceT r i Identity aSource

The choice monad. Derived from ChoiceT.

listChoice :: Choice [a] [a] a -> [a]Source

Get list of solutions.

maybeChoice :: Choice (Maybe a) (Maybe a) a -> Maybe aSource

Get one solution.

Cont

type Cont r a = ContT r Identity aSource

Pure CPS monad derived from ContT.

runCont :: (a -> r) -> Cont r a -> rSource

Run a pure CPS computation.

evalCont :: Cont r r -> rSource

Evaluate a pure CPS computation to its final result.

modifyCont :: (r -> r) -> Cont r ()Source

Modify the result of a CPS computation along the way.

Reader

type Reader e a = ReaderT e Identity aSource

Pure computation with environment.

runReader :: e -> Reader e a -> aSource

Run a pure computation with environment.

State

type State r s a = StateT r s Identity aSource

Pure state monad derived from StateT.

runState :: s -> (a -> s -> r) -> State r s a -> rSource

Run a stateful computation.

evalState :: s -> State r s r -> rSource

Run a stateful computation returning its result.

execState :: s -> State s s a -> sSource

Run a stateful computation returning its result.

Writer

type OldWriter r w a = ContT (r, w) Identity aSource

The traditional writer monad.

runOldWriter :: Monoid w => OldWriter r w r -> (r, w)Source

Run a traditional writer computation.

evalOldWriter :: Monoid w => OldWriter r w r -> rSource

Run a traditional writer computation and return its result.

execOldWriter :: Monoid w => OldWriter r w r -> wSource

Run a traditional writer computation and return its log.