|
|
|
|
|
| Description |
| This library provides a collection of monad transformers that
can be combined to produce various monads.
|
|
| Synopsis |
|
|
|
|
| Types
|
|
| The following types define the representations of the
computation types supported by the library.
Each type adds support for a different effect.
|
|
|
| Computations with no effects.
| Instances | |
|
|
|
| Computation with no effects (strict).
| Instances | |
|
|
|
| Adds no new features. Useful as a placeholder.
| Instances | |
|
|
|
| Add support for propagating a context of type i.
| Instances | |
|
|
|
| Add support for collecting values of type i.
The type i should be a monoid, whose unit is used to represent
a lack of a value, and whose binary operation is used to combine
multiple values.
This transformer is strict in its output component.
| Instances | | Monoid i => MonadT (WriterT i) | | (Monad m, Monoid i) => Monad (WriterT i m) | | (Monad m, Monoid i) => Functor (WriterT i m) | | (MonadFix m, Monoid i) => MonadFix (WriterT i m) | | (MonadPlus m, Monoid i) => MonadPlus (WriterT i m) | | (Monad m, Monoid i) => Applicative (WriterT i m) | | (MonadPlus m, Monoid i) => Alternative (WriterT i m) | | (ContM m, Monoid i) => ContM (WriterT i m) | | (RunReaderM m j, Monoid i) => RunReaderM (WriterT i m) j | | (Monad m, Monoid i) => RunWriterM (WriterT i m) i | | (RunExceptionM m i, Monoid j) => RunExceptionM (WriterT j m) i | | (ExceptionM m j, Monoid i) => ExceptionM (WriterT i m) j | | (StateM m j, Monoid i) => StateM (WriterT i m) j | | (Monad m, Monoid i) => WriterM (WriterT i m) i | | (ReaderM m j, Monoid i) => ReaderM (WriterT i m) j | | (BaseM m n, Monoid i) => BaseM (WriterT i m) n |
|
|
|
|
| Add support for threading state of type i.
| Instances | |
|
|
|
| Add support for exceptions of type i.
| Instances | |
|
|
About the WriterM instance:
If an exception is risen while we are collecting output,
then the output is lost. If the output is important,
then use try to ensure that no exception may occur.
Example:
do (r,w) <- collect (try m)
case r of
Left err -> ...do something...
Right a -> ...do something...
|
|
|
| Add support for multiple answers.
| Instances | |
|
|
|
| Add support for continuations within a prompt of type i.
| Instances | |
|
|
| Lifting
|
|
| The following operations allow us to promote computations
in the underlying monad to computations that support an extra
effect. Computations defined in this way do not make use of
the new effect but can be combined with other operations that
utilize the effect.
|
|
|
| | Methods | | | Promote a computation from the underlying monad.
|
| | Instances | |
|
|
|
| | Methods | | | Promote a computation from the base monad.
|
| | Instances | |
|
|
| Effect Classes
|
|
| The following classes define overloaded operations
that can be used to define effectful computations.
|
|
|
| Classifies monads that provide access to a context of type i.
| | | Methods | | | Instances | |
|
|
|
| Classifies monads that can collect values of type i.
| | | Methods | | | Add a value to the collection.
|
| | Instances | |
|
|
|
| Classifies monads that propagate a state component of type i.
| | | Methods | | | Get the state.
| | | | Set the state.
|
| | Instances | |
|
|
|
| Classifies monads that support raising exceptions of type i.
| | | Methods | | | Instances | |
|
|
|
| Classifies monads that provide access to a computation's continuation.
| | | Methods | | callCC :: ((a -> m b) -> m a) -> m a | Source |
| | Capture the current continuation.
|
| | Instances | |
|
|
|
| An explicit representation for continuations that store a value.
|
|
|
|
| Capture the current continuation.
This function is like return, except that it also captures
the current continuation. Later, we can use jump to repeat the
computation from this point onwards but with a possibly different value.
|
|
|
| Change the value passed to a previously captured continuation.
|
|
| Execution
|
|
| Eliminating Effects
|
|
| The following functions eliminate the outermost effect
of a computation by translating a computation into an
equivalent computation in the underlying monad.
(The exceptions are Id and Lift which are not transformers
but ordinary monas and so, their run operations simply
eliminate the monad.)
|
|
|
| Get the result of a pure computation.
|
|
|
| Get the result of a pure strict computation.
|
|
|
| Remove an identity layer.
|
|
|
| Execute a reader computation in the given context.
|
|
|
| Execute a writer computation.
Returns the result and the collected output.
|
|
|
| Execute a stateful computation in the given initial state.
The second component of the result is the final state.
|
|
|
| Execute a computation with exceptions.
Successful results are tagged with Right,
exceptional results are tagged with Left.
|
|
|
| Execute a computation with the given continuation.
|
|
|
| Execute a computation that may return multiple answers.
The resulting computation returns Nothing
if no answers were found, or Just (answer,new_comp),
where answer is an answer, and new_comp is a computation
that may produce more answers.
The search is depth-first and left-biased with respect to the
mplus operation.
|
|
|
| Execute a computation that may return multiple answers,
returning at most one answer.
|
|
|
| Executie a computation that may return multiple answers,
collecting all possible answers.
|
|
| Nested Execution
|
|
| The following classes define operations that are overloaded
versions of the run operations. Unlike the run operations,
these functions do not change the type of the computation (i.e, they
do not remove a layer). Instead, they perform the effects in
a ``separate effect thread''.
|
|
|
| Classifies monads that support changing the context for a
sub-computation.
| | | Methods | | local :: i -> m a -> m a | Source |
| | Change the context for the duration of a sub-computation.
|
| | Instances | |
|
|
|
| Classifies monads that support collecting the output of
a sub-computation.
| | | Methods | | collect :: m a -> m (a, i) | Source |
| | Collect the output from a sub-computation.
|
| | Instances | |
|
|
|
| Classifies monads that support handling of exceptions.
| | | Methods | | | Convert computations that may raise an exception
into computations that do not raise exception but instead,
yield a tagged results. Exceptions are tagged with Left,
successful computations are tagged with Right.
|
| | Instances | |
|
|
| Miscellaneous
|
|
|
| The current version of the library.
|
|
| Produced by Haddock version 2.1.0 |