Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 1f2b142b9d2ef4849a6f5316fa1c5b12 > files > 2588

ghc-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.Error.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-Error-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.Error.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 may fail or throw exceptions.
</DD
><DT
>Binding strategy:</DT
><DD
> Failure records information about the cause/location
of the failure. Failure values bypass the bound function,
other values are used as inputs to the bound function.
</DD
><DT
>Useful for:</DT
><DD
> Building computations from sequences of functions that may fail
or using exception handling to structure error handling.
</DD
><DT
>Zero and plus:</DT
><DD
> Zero is represented by an empty error and the plus operation
executes its second argument if the first fails.
</DD
><DT
>Example type:</DT
><DD
> <TT
>Data.Either String a</TT
>
</DD
></DL
><P
>The Error monad (also called the Exception monad).
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>class</SPAN
>  <A HREF="#t%3AError"
>Error</A
> a  <SPAN CLASS="keyword"
>where</SPAN
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="#v%3AnoMsg"
>noMsg</A
> :: a</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AstrMsg"
>strMsg</A
> :: <A HREF="../base/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>class</SPAN
> <A HREF="../base/Control-Monad.html#t%3AMonad"
>Monad</A
> m =&gt; <A HREF="#t%3AMonadError"
>MonadError</A
> e m | m -&gt; e <SPAN CLASS="keyword"
>where</SPAN
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="#v%3AthrowError"
>throwError</A
> ::  e -&gt; m a</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AcatchError"
>catchError</A
> ::  m a -&gt; (e -&gt; m a) -&gt; m a</TD
></TR
></TABLE
></TD
></TR
></TABLE
></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 NAME="t:Error"
><A NAME="t%3AError"
></A
></A
><B
>Error</B
> a  <SPAN CLASS="keyword"
>where</SPAN
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
>An exception to be thrown.
 An instance must redefine at least one of <TT
><A HREF="Control-Monad-Error-Class.html#v%3AnoMsg"
>noMsg</A
></TT
>, <TT
><A HREF="Control-Monad-Error-Class.html#v%3AstrMsg"
>strMsg</A
></TT
>.
</TD
></TR
><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:noMsg"
><A NAME="v%3AnoMsg"
></A
></A
><B
>noMsg</B
> :: a</TD
></TR
><TR
><TD CLASS="doc"
>Creates an exception without a message.
 Default implementation is <TT
><TT
><A HREF="Control-Monad-Error-Class.html#v%3AstrMsg"
>strMsg</A
></TT
> &quot;&quot;</TT
>.
</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:strMsg"
><A NAME="v%3AstrMsg"
></A
></A
><B
>strMsg</B
> :: <A HREF="../base/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="doc"
>Creates an exception with a message.
 Default implementation is <TT
><A HREF="Control-Monad-Error-Class.html#v%3AnoMsg"
>noMsg</A
></TT
>.
</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:Error')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:Error" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
> <A HREF="../base/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
> <A HREF="../base/System-IO-Error.html#t%3AIOError"
>IOError</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></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:MonadError"
><A NAME="t%3AMonadError"
></A
></A
><B
>MonadError</B
> e m | m -&gt; e <SPAN CLASS="keyword"
>where</SPAN
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
><P
>The strategy of combining computations that can throw exceptions
by bypassing bound functions
from the point an exception is thrown to the point that it is handled.
</P
><P
>Is parameterized over the type of error information and
the monad type constructor.
It is common to use <TT
>Data.Either String</TT
> as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the <TT
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
></TT
> class.
You can also define your own error type and/or use a monad type constructor
other than <TT
>Data.Either String</TT
> or <TT
>Data.Either IOError</TT
>.
In these cases you will have to explicitly define instances of the <TT
><A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
></TT
>
and/or <TT
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
></TT
> classes.
</P
></TD
></TR
><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:throwError"
><A NAME="v%3AthrowError"
></A
></A
><B
>throwError</B
> ::  e -&gt; m a</TD
></TR
><TR
><TD CLASS="doc"
>Is used within a monadic computation to begin exception processing.
</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:catchError"
><A NAME="v%3AcatchError"
></A
></A
><B
>catchError</B
> ::  m a -&gt; (e -&gt; m a) -&gt; m a</TD
></TR
><TR
><TD CLASS="doc"
><P
>A handler function to handle previous errors and return to normal execution.
    A common idiom is:
</P
><PRE
> do { action1; action2; action3 } `catchError` handler
</PRE
><P
>where the <TT
>action</TT
> functions can call <TT
><A HREF="Control-Monad-Error-Class.html#v%3AthrowError"
>throwError</A
></TT
>.
    Note that <TT
>handler</TT
> and the do-block must have the same return type.
</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:MonadError')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:MonadError" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> <A HREF="../base/System-IO-Error.html#t%3AIOError"
>IOError</A
> <A HREF="../base/System-IO.html#t%3AIO"
>IO</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> <A HREF="../base/System-IO-Error.html#t%3AIOError"
>IOError</A
> <A HREF="../base/System-IO.html#t%3AIO"
>IO</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
> e =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="../base/Data-Either.html#t%3AEither"
>Either</A
> e)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="Control-Monad-List.html#t%3AListT"
>ListT</A
> m)</TD
></TR
><TR
><TD CLASS="decl"
>(<A HREF="../base/Control-Monad.html#t%3AMonad"
>Monad</A
> m, <A HREF="Control-Monad-Error-Class.html#t%3AError"
>Error</A
> e) =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="Control-Monad-Error.html#t%3AErrorT"
>ErrorT</A
> e m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="Control-Monad-Reader.html#t%3AReaderT"
>ReaderT</A
> r m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="Control-Monad-State-Lazy.html#t%3AStateT"
>StateT</A
> s m)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<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-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m) =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<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-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m) =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<A HREF="Control-Monad-Writer-Strict.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-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m) =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<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-Error-Class.html#t%3AMonadError"
>MonadError</A
> e m) =&gt; <A HREF="Control-Monad-Error-Class.html#t%3AMonadError"
>MonadError</A
> e (<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
>