Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 70ec89744a04da80369b4702b2c37256 > files > 1435

ghc-doc-6.10.4-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Control.Monad.Cont.Class</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_Control-Monad-Cont-Class.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>mtl-1.1.0.2: Monad transformer library</TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Control.Monad.Cont.Class</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>non-portable (multi-parameter type classes)</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>experimental</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>libraries@haskell.org</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><DL
><DT
>Computation type:</DT
><DD
> Computations which can be interrupted and resumed.
</DD
><DT
>Binding strategy:</DT
><DD
> Binding a function to a monadic value creates
a new continuation which uses the function as the continuation of the monadic
computation.
</DD
><DT
>Useful for:</DT
><DD
> Complex control structures, error handling,
and creating co-routines.
</DD
><DT
>Zero and plus:</DT
><DD
> None.
</DD
><DT
>Example type:</DT
><DD
> <TT
>Cont r a</TT
>
</DD
></DL
><P
>The Continuation monad represents computations in continuation-passing style
(CPS).
In continuation-passing style function result is not returned,
but instead is passed to another function,
received as a parameter (continuation).
Computations are built up from sequences
of nested continuations, terminated by a final continuation (often <TT
>id</TT
>)
which produces the final result.
Since continuations are functions which represent the future of a computation,
manipulation of the continuation functions can achieve complex manipulations
of the future of the computation,
such as interrupting a computation in the middle, aborting a portion
of a computation, restarting a computation, and interleaving execution of
computations.
The Continuation monad adapts CPS to the structure of a monad.
</P
><P
>Before using the Continuation monad, be sure that you have
a firm understanding of continuation-passing style
and that continuations represent the best solution to your particular
design problem.
Many algorithms which require continuations in other languages do not require
them in Haskell, due to Haskell's lazy semantics.
Abuse of the Continuation monad can produce code that is impossible
to understand and maintain.
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Documentation</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>class</SPAN
> <A HREF="../base/Control-Monad.html#t%3AMonad"
>Monad</A
> m =&gt; <A NAME="t:MonadCont"
><A NAME="t%3AMonadCont"
></A
></A
><B
>MonadCont</B
> m  <SPAN CLASS="keyword"
>where</SPAN
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="section4"
>Methods</TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A NAME="v:callCC"
><A NAME="v%3AcallCC"
></A
></A
><B
>callCC</B
> ::  ((a -&gt; m b) -&gt; m a) -&gt; m a</TD
></TR
><TR
><TD CLASS="doc"
><P
><TT
>callCC</TT
> (call-with-current-continuation)
    calls a function with the current continuation as its argument.
    Provides an escape continuation mechanism for use with Continuation monads.
    Escape continuations allow to abort the current computation and return
    a value immediately.
    They achieve a similar effect to Control.Monad.Error.throwError
    and Control.Monad.Error.catchError
    within an Control.Monad.Error.Error monad.
    Advantage of this function over calling <TT
>return</TT
> is that it makes
    the continuation explicit,
    allowing more flexibility and better control
    (see examples in <A HREF="Control-Monad-Cont.html"
>Control.Monad.Cont</A
>).
</P
><P
>The standard idiom used with <TT
>callCC</TT
> is to provide a lambda-expression
    to name the continuation. Then calling the named continuation anywhere
    within its scope will escape from the computation,
    even if it is many layers deep within nested computations.
</P
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:MonadCont')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:MonadCont" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-List.html#t%3AListT"
>ListT</A
> m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Cont.html#t%3ACont"
>Cont</A
> r)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
> e, <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m) =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Error.html#t%3AErrorT"
>ErrorT</A
> e m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Reader.html#t%3AReaderT"
>ReaderT</A
> r m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-State-Lazy.html#t%3AStateT"
>StateT</A
> s m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-State-Strict.html#t%3AStateT"
>StateT</A
> s m)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="../base/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> w, <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m) =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Writer-Lazy.html#t%3AWriterT"
>WriterT</A
> w m)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="../base/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> w, <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m) =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Writer-Strict.html#t%3AWriterT"
>WriterT</A
> w m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="../base/Control-Monad.html#t%3AMonad"
>Monad</A
> m =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-Cont.html#t%3AContT"
>ContT</A
> r m)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="../base/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> w, <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m) =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-RWS-Lazy.html#t%3ARWST"
>RWST</A
> r w s m)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="../base/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> w, <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> m) =&gt; <A HREF="Control-Monad-Cont-Class.html#t%3AMonadCont"
>MonadCont</A
> (<A HREF="Control-Monad-RWS-Strict.html#t%3ARWST"
>RWST</A
> r w s m)</TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.4.2</TD
></TR
></TABLE
></BODY
></HTML
>