Monad package:ghc
The
Monad class defines the basic operations over a
monad, a concept from a branch of mathematics known as
category theory. From the perspective of a Haskell programmer,
however, it is best to think of a monad as an
abstract datatype
of actions. Haskell's
do expressions provide a convenient
syntax for writing monadic expressions.
Instances of
Monad should satisfy the following:
Furthermore, the
Monad and
Applicative operations should
relate as follows:
The above laws imply:
and that
pure and (
<*>) satisfy the applicative
functor laws.
The instances of
Monad for lists,
Maybe and
IO
defined in the
Prelude satisfy these laws.
Hides away distracting bookkeeping while lambda lifting into a
LiftM monad.
Monadic definitions for the constraint solver
Functions for working with the typechecker environment (setters,
getters...).
Utilities related to Monad and Applicative classes Mostly for
backwards compatibility.
A monad for generating unique identifiers
Module : GHC.Data.Graph.Collapse Description : Implement the
"collapsing" algorithm Hecht and Ullman
A control-flow graph is reducible if and only if it is collapsible
according to the definition of Hecht and Ullman (1972). This module
implements the collapsing algorithm of Hecht and Ullman, and if it
encounters a graph that is not collapsible, it splits nodes until the
graph is fully collapsed. It then reports what nodes (if any) had to
be split in order to collapse the graph. The information is used
upstream to node-split Cmm graphs.
The module uses the inductive graph representation cloned from the
Functional Graph Library (Hackage package
fgl, modules
*.)
If you want to visualize the graph-collapsing algorithm, create an
instance of monad
VizCollapseMonad. Each step in the algorithm
is announced to the monad as a side effect. If you don't care about
visualization, you would use the
NullCollapseViz monad, in
which these operations are no-ops.
Lift a f action into an m action.
An mtl-style class for monads that support parsing-related operations.
For example, sometimes we make a second pass over the parsing results
to validate, disambiguate, or rearrange them, and we do so in the PV
monad which cannot consume input but can report parsing errors, check
for extension bits, and accumulate parsing annotations. Both P and PV
are instances of MonadP.
MonadP grants us convenient overloading. The other option is to have
separate operations for each monad: addErrorP vs addErrorPV, getBitP
vs getBitPV, and so on.
When a value is bound in
do-notation, the pattern on the left
hand side of
<- might not match. In this case, this class
provides a function to recover.
A
Monad without a
MonadFail instance may only be used in
conjunction with pattern that always match, such as newtypes, tuples,
data types with only a single data constructor, and irrefutable
patterns (
~pat).
Instances of
MonadFail should satisfy the following law:
fail s should be a left zero for
>>=,
fail s >>= f = fail s
If your
Monad is also
MonadPlus, a popular definition is
fail _ = mzero
fail s should be an action that runs in the monad itself, not
an exception (except in instances of
MonadIO). In particular,
fail should not be implemented in terms of
error.
Class that abstracts out the common ability of the monads in GHC to
lookup a
TyThing in the monadic environment by
Name.
Provides a number of related convenience functions for accessing
particular kinds of
TyThing
Monads having fixed points with a 'knot-tying' semantics. Instances of
MonadFix should satisfy the following laws:
This class is used in the translation of the recursive
do
notation supported by GHC and Hugs.
Monads in which
IO computations may be embedded. Any monad
built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that
liftIO is a transformer of monads: