<!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.Exception.Base</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-Exception-Base.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" >base-4.2.0.2: Basic libraries</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.Exception.Base</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >non-portable (extended exceptions)</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 ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" ><B >Contents</B ></TD ></TR ><TR ><TD ><DL ><DT ><A HREF="#1" >The Exception type </A ></DT ><DT ><A HREF="#2" >Throwing exceptions </A ></DT ><DT ><A HREF="#3" >Catching Exceptions </A ></DT ><DD ><DL ><DT ><A HREF="#4" >The <TT >catch</TT > functions </A ></DT ><DT ><A HREF="#5" >The <TT >handle</TT > functions </A ></DT ><DT ><A HREF="#6" >The <TT >try</TT > functions </A ></DT ><DT ><A HREF="#7" >The <TT >evaluate</TT > function </A ></DT ><DT ><A HREF="#8" >The <TT >mapException</TT > function </A ></DT ></DL ></DD ><DT ><A HREF="#9" >Asynchronous Exceptions </A ></DT ><DD ><DL ><DT ><A HREF="#10" >Asynchronous exception control </A ></DT ></DL ></DD ><DT ><A HREF="#11" >Assertions </A ></DT ><DT ><A HREF="#12" >Utilities </A ></DT ><DT ><A HREF="#13" >Calls for GHC runtime </A ></DT ></DL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >Extensible exceptions, except for multiple handlers. </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" >data</SPAN > <A HREF="#t%3ASomeException" >SomeException</A > = <SPAN CLASS="keyword" >forall</SPAN > e . <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="#v%3ASomeException" >SomeException</A > e</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >class</SPAN > (<A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > e, <A HREF="Text-Show.html#t%3AShow" >Show</A > e) => <A HREF="#t%3AException" >Exception</A > 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%3AtoException" >toException</A > :: e -> <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AfromException" >fromException</A > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A > -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > e</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AIOException" >IOException</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AArithException" >ArithException</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AOverflow" >Overflow</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AUnderflow" >Underflow</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ALossOfPrecision" >LossOfPrecision</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ADivideByZero" >DivideByZero</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ADenormal" >Denormal</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AArrayException" >ArrayException</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AIndexOutOfBounds" >IndexOutOfBounds</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AUndefinedElement" >UndefinedElement</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AAssertionFailed" >AssertionFailed</A > = <A HREF="#v%3AAssertionFailed" >AssertionFailed</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AAsyncException" >AsyncException</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AStackOverflow" >StackOverflow</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AHeapOverflow" >HeapOverflow</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AThreadKilled" >ThreadKilled</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AUserInterrupt" >UserInterrupt</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ANonTermination" >NonTermination</A > = <A HREF="#v%3ANonTermination" >NonTermination</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ANestedAtomically" >NestedAtomically</A > = <A HREF="#v%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A > = <A HREF="#v%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A > = <A HREF="#v%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ADeadlock" >Deadlock</A > = <A HREF="#v%3ADeadlock" >Deadlock</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ANoMethodError" >NoMethodError</A > = <A HREF="#v%3ANoMethodError" >NoMethodError</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3APatternMatchFail" >PatternMatchFail</A > = <A HREF="#v%3APatternMatchFail" >PatternMatchFail</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ARecConError" >RecConError</A > = <A HREF="#v%3ARecConError" >RecConError</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ARecSelError" >RecSelError</A > = <A HREF="#v%3ARecSelError" >RecSelError</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ARecUpdError" >RecUpdError</A > = <A HREF="#v%3ARecUpdError" >RecUpdError</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AErrorCall" >ErrorCall</A > = <A HREF="#v%3AErrorCall" >ErrorCall</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AthrowIO" >throwIO</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Athrow" >throw</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => e -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AioError" >ioError</A > :: <A HREF="System-IO-Error.html#t%3AIOError" >IOError</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AthrowTo" >throwTo</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="Control-Concurrent.html#t%3AThreadId" >ThreadId</A > -> e -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Acatch" >catch</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="System-IO.html#t%3AIO" >IO</A > a -> (e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AcatchJust" >catchJust</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> (b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Ahandle" >handle</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhandleJust" >handleJust</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> (b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Atry" >try</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Either.html#t%3AEither" >Either</A > e a)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtryJust" >tryJust</A > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Either.html#t%3AEither" >Either</A > b a)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AonException" >onException</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aevaluate" >evaluate</A > :: a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AmapException" >mapException</A > :: (<A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e1, <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e2) => (e1 -> e2) -> a -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Ablock" >block</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aunblock" >unblock</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Ablocked" >blocked</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aassert" >assert</A > :: <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> a -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Abracket" >bracket</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> (a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b) -> (a -> <A HREF="System-IO.html#t%3AIO" >IO</A > c) -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Abracket_" >bracket_</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b -> <A HREF="System-IO.html#t%3AIO" >IO</A > c -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AbracketOnError" >bracketOnError</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> (a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b) -> (a -> <A HREF="System-IO.html#t%3AIO" >IO</A > c) -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Afinally" >finally</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArecSelError" >recSelError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArecConError" >recConError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AirrefutPatError" >irrefutPatError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AruntimeError" >runtimeError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnonExhaustiveGuardsError" >nonExhaustiveGuardsError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ApatError" >patError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnoMethodBindingError" >noMethodBindingError</A > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnonTermination" >nonTermination</A > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnestedAtomically" >nestedAtomically</A > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="1" ><A NAME="1" >The Exception type </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:SomeException" ><A NAME="t%3ASomeException" ></A ></A ><B >SomeException</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >The <TT >SomeException</TT > type is the root of the exception type hierarchy. When an exception of type <TT >e</TT > is thrown, behind the scenes it is encapsulated in a <TT >SomeException</TT >. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><SPAN CLASS="keyword" >forall</SPAN > e . <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A NAME="v:SomeException" ><A NAME="v%3ASomeException" ></A ></A ><B >SomeException</B > e</TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:SomeException')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:SomeException" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</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="Data-Typeable.html#t%3ATypeable" >Typeable</A > e, <A HREF="Text-Show.html#t%3AShow" >Show</A > e) => <A NAME="t:Exception" ><A NAME="t%3AException" ></A ></A ><B >Exception</B > e <SPAN CLASS="keyword" >where</SPAN ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><P >Any type that you wish to throw or catch as an exception must be an instance of the <TT >Exception</TT > class. The simplest case is a new exception type directly below the root: </P ><PRE > data MyException = ThisException | ThatException deriving (Show, Typeable) instance Exception MyException </PRE ><P >The default method definitions in the <TT >Exception</TT > class do what we need in this case. You can now throw and catch <TT >ThisException</TT > and <TT >ThatException</TT > as exceptions: </P ><PRE > *Main> throw ThisException catch e -> putStrLn ("Caught " ++ show (e :: MyException)) Caught ThisException </PRE ><P >In more complicated examples, you may wish to define a whole hierarchy of exceptions: </P ><PRE > --------------------------------------------------------------------- -- Make the root exception type for all the exceptions in a compiler data SomeCompilerException = forall e . Exception e => SomeCompilerException e deriving Typeable instance Show SomeCompilerException where show (SomeCompilerException e) = show e instance Exception SomeCompilerException compilerExceptionToException :: Exception e => e -> SomeException compilerExceptionToException = toException . SomeCompilerException compilerExceptionFromException :: Exception e => SomeException -> Maybe e compilerExceptionFromException x = do SomeCompilerException a <- fromException x cast a --------------------------------------------------------------------- -- Make a subhierarchy for exceptions in the frontend of the compiler data SomeFrontendException = forall e . Exception e => SomeFrontendException e deriving Typeable instance Show SomeFrontendException where show (SomeFrontendException e) = show e instance Exception SomeFrontendException where toException = compilerExceptionToException fromException = compilerExceptionFromException frontendExceptionToException :: Exception e => e -> SomeException frontendExceptionToException = toException . SomeFrontendException frontendExceptionFromException :: Exception e => SomeException -> Maybe e frontendExceptionFromException x = do SomeFrontendException a <- fromException x cast a --------------------------------------------------------------------- -- Make an exception type for a particular frontend compiler exception data MismatchedParentheses = MismatchedParentheses deriving (Typeable, Show) instance Exception MismatchedParentheses where toException = frontendExceptionToException fromException = frontendExceptionFromException </PRE ><P >We can now catch a <TT >MismatchedParentheses</TT > exception as <TT >MismatchedParentheses</TT >, <TT >SomeFrontendException</TT > or <TT >SomeCompilerException</TT >, but not other types, e.g. <TT >IOException</TT >: </P ><PRE > *Main> throw MismatchedParentheses catch e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses)) Caught MismatchedParentheses *Main> throw MismatchedParentheses catch e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException)) Caught MismatchedParentheses *Main> throw MismatchedParentheses catch e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException)) Caught MismatchedParentheses *Main> throw MismatchedParentheses catch e -> putStrLn ("Caught " ++ show (e :: IOException)) *** Exception: MismatchedParentheses </PRE ></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:toException" ><A NAME="v%3AtoException" ></A ></A ><B >toException</B > :: e -> <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:fromException" ><A NAME="v%3AfromException" ></A ></A ><B >fromException</B > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A > -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > e</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:Exception')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Exception" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AErrorCall" >ErrorCall</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AIOException" >IOException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Data-Dynamic.html#t%3ADynamic" >Dynamic</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AAssertionFailed" >AssertionFailed</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ADeadlock" >Deadlock</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > BlockedIndefinitely</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > BlockedOnDeadMVar</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANonTermination" >NonTermination</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANoMethodError" >NoMethodError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecUpdError" >RecUpdError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecConError" >RecConError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecSelError" >RecSelError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3APatternMatchFail" >PatternMatchFail</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > Timeout</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-OldException.html#t%3AException" >Exception</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:IOException" ><A NAME="t%3AIOException" ></A ></A ><B >IOException</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Exceptions that occur in the <TT >IO</TT > monad. An <TT >IOException</TT > records a more specific error type, a descriptive string and maybe the handle that was used when the error was flagged. </TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:IOException')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:IOException" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Control-Exception-Base.html#t%3AIOException" >IOException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AIOException" >IOException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AIOException" >IOException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AIOException" >IOException</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:ArithException" ><A NAME="t%3AArithException" ></A ></A ><B >ArithException</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Arithmetic exceptions. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:Overflow" ><A NAME="v%3AOverflow" ></A ></A ><B >Overflow</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:Underflow" ><A NAME="v%3AUnderflow" ></A ></A ><B >Underflow</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:LossOfPrecision" ><A NAME="v%3ALossOfPrecision" ></A ></A ><B >LossOfPrecision</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:DivideByZero" ><A NAME="v%3ADivideByZero" ></A ></A ><B >DivideByZero</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:Denormal" ><A NAME="v%3ADenormal" ></A ></A ><B >Denormal</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ArithException')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:ArithException" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AArithException" >ArithException</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:ArrayException" ><A NAME="t%3AArrayException" ></A ></A ><B >ArrayException</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Exceptions generated by array operations </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:IndexOutOfBounds" ><A NAME="v%3AIndexOutOfBounds" ></A ></A ><B >IndexOutOfBounds</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >An attempt was made to index an array outside its declared bounds. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:UndefinedElement" ><A NAME="v%3AUndefinedElement" ></A ></A ><B >UndefinedElement</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >An attempt was made to evaluate an element of an array that had not been initialized. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ArrayException')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:ArrayException" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AArrayException" >ArrayException</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:AssertionFailed" ><A NAME="t%3AAssertionFailed" ></A ></A ><B >AssertionFailed</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><TT ><A HREF="Control-Exception-Base.html#v%3Aassert" >assert</A ></TT > was applied to <TT ><A HREF="Data-Bool.html#v%3AFalse" >False</A ></TT >. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:AssertionFailed" ><A NAME="v%3AAssertionFailed" ></A ></A ><B >AssertionFailed</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:AssertionFailed')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:AssertionFailed" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AAssertionFailed" >AssertionFailed</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AAssertionFailed" >AssertionFailed</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AAssertionFailed" >AssertionFailed</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:AsyncException" ><A NAME="t%3AAsyncException" ></A ></A ><B >AsyncException</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Asynchronous exceptions. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:StackOverflow" ><A NAME="v%3AStackOverflow" ></A ></A ><B >StackOverflow</B ></TD ><TD CLASS="rdoc" >The current thread's stack exceeded its limit. Since an exception has been raised, the thread's stack will certainly be below its limit again, but the programmer should take remedial action immediately. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:HeapOverflow" ><A NAME="v%3AHeapOverflow" ></A ></A ><B >HeapOverflow</B ></TD ><TD CLASS="rdoc" ><P >The program's heap is reaching its limit, and the program should take action to reduce the amount of live data it has. Notes: </P ><UL ><LI > It is undefined which thread receives this exception. </LI ><LI > GHC currently does not throw <TT ><A HREF="Control-Exception-Base.html#v%3AHeapOverflow" >HeapOverflow</A ></TT > exceptions. </LI ></UL ></TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:ThreadKilled" ><A NAME="v%3AThreadKilled" ></A ></A ><B >ThreadKilled</B ></TD ><TD CLASS="rdoc" >This exception is raised by another thread calling Control.Concurrent.killThread, or by the system if it needs to terminate the thread for some reason. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:UserInterrupt" ><A NAME="v%3AUserInterrupt" ></A ></A ><B >UserInterrupt</B ></TD ><TD CLASS="rdoc" >This exception is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console). </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:AsyncException')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:AsyncException" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AAsyncException" >AsyncException</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:NonTermination" ><A NAME="t%3ANonTermination" ></A ></A ><B >NonTermination</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Thrown when the runtime system detects that the computation is guaranteed not to terminate. Note that there is no guarantee that the runtime system will notice whether any given computation is guaranteed to terminate or not. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:NonTermination" ><A NAME="v%3ANonTermination" ></A ></A ><B >NonTermination</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NonTermination')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:NonTermination" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ANonTermination" >NonTermination</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ANonTermination" >NonTermination</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANonTermination" >NonTermination</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:NestedAtomically" ><A NAME="t%3ANestedAtomically" ></A ></A ><B >NestedAtomically</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Thrown when the program attempts to call <TT >atomically</TT >, from the <TT >stm</TT > package, inside another call to <TT >atomically</TT >. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:NestedAtomically" ><A NAME="v%3ANestedAtomically" ></A ></A ><B >NestedAtomically</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NestedAtomically')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:NestedAtomically" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:BlockedIndefinitelyOnMVar" ><A NAME="t%3ABlockedIndefinitelyOnMVar" ></A ></A ><B >BlockedIndefinitelyOnMVar</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >The thread is blocked on an <TT >MVar</TT >, but there are no other references to the <TT >MVar</TT > so it can't ever continue. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:BlockedIndefinitelyOnMVar" ><A NAME="v%3ABlockedIndefinitelyOnMVar" ></A ></A ><B >BlockedIndefinitelyOnMVar</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:BlockedIndefinitelyOnMVar')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:BlockedIndefinitelyOnMVar" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnMVar" >BlockedIndefinitelyOnMVar</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:BlockedIndefinitelyOnSTM" ><A NAME="t%3ABlockedIndefinitelyOnSTM" ></A ></A ><B >BlockedIndefinitelyOnSTM</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >The thread is waiting to retry an STM transaction, but there are no other references to any <TT >TVar</TT >s involved, so it can't ever continue. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:BlockedIndefinitelyOnSTM" ><A NAME="v%3ABlockedIndefinitelyOnSTM" ></A ></A ><B >BlockedIndefinitelyOnSTM</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:BlockedIndefinitelyOnSTM')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:BlockedIndefinitelyOnSTM" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ABlockedIndefinitelyOnSTM" >BlockedIndefinitelyOnSTM</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Deadlock" ><A NAME="t%3ADeadlock" ></A ></A ><B >Deadlock</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >There are no runnable threads, so the program is deadlocked. The <TT >Deadlock</TT > exception is raised in the main thread only. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:Deadlock" ><A NAME="v%3ADeadlock" ></A ></A ><B >Deadlock</B ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Deadlock')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Deadlock" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ADeadlock" >Deadlock</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ADeadlock" >Deadlock</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ADeadlock" >Deadlock</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:NoMethodError" ><A NAME="t%3ANoMethodError" ></A ></A ><B >NoMethodError</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >A class method without a definition (neither a default definition, nor a definition in the appropriate instance) was called. The <TT >String</TT > gives information about which method it was. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:NoMethodError" ><A NAME="v%3ANoMethodError" ></A ></A ><B >NoMethodError</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NoMethodError')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:NoMethodError" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ANoMethodError" >NoMethodError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ANoMethodError" >NoMethodError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ANoMethodError" >NoMethodError</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:PatternMatchFail" ><A NAME="t%3APatternMatchFail" ></A ></A ><B >PatternMatchFail</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >A pattern match failed. The <TT >String</TT > gives information about the source location of the pattern. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:PatternMatchFail" ><A NAME="v%3APatternMatchFail" ></A ></A ><B >PatternMatchFail</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:PatternMatchFail')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:PatternMatchFail" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3APatternMatchFail" >PatternMatchFail</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3APatternMatchFail" >PatternMatchFail</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3APatternMatchFail" >PatternMatchFail</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:RecConError" ><A NAME="t%3ARecConError" ></A ></A ><B >RecConError</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >An uninitialised record field was used. The <TT >String</TT > gives information about the source location where the record was constructed. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:RecConError" ><A NAME="v%3ARecConError" ></A ></A ><B >RecConError</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:RecConError')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:RecConError" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ARecConError" >RecConError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ARecConError" >RecConError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecConError" >RecConError</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:RecSelError" ><A NAME="t%3ARecSelError" ></A ></A ><B >RecSelError</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >A record selector was applied to a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another. The <TT >String</TT > gives information about the source location of the record selector. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:RecSelError" ><A NAME="v%3ARecSelError" ></A ></A ><B >RecSelError</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:RecSelError')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:RecSelError" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ARecSelError" >RecSelError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ARecSelError" >RecSelError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecSelError" >RecSelError</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:RecUpdError" ><A NAME="t%3ARecUpdError" ></A ></A ><B >RecUpdError</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >A record update was performed on a constructor without the appropriate field. This can only happen with a datatype with multiple constructors, where some fields are in one constructor but not another. The <TT >String</TT > gives information about the source location of the record update. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:RecUpdError" ><A NAME="v%3ARecUpdError" ></A ></A ><B >RecUpdError</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:RecUpdError')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:RecUpdError" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3ARecUpdError" >RecUpdError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3ARecUpdError" >RecUpdError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3ARecUpdError" >RecUpdError</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:ErrorCall" ><A NAME="t%3AErrorCall" ></A ></A ><B >ErrorCall</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >This is thrown when the user calls <TT ><A HREF="Prelude.html#v%3Aerror" >error</A ></TT >. The <TT >String</TT > is the argument given to <TT ><A HREF="Prelude.html#v%3Aerror" >error</A ></TT >. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:ErrorCall" ><A NAME="v%3AErrorCall" ></A ></A ><B >ErrorCall</B > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ErrorCall')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:ErrorCall" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="Control-Exception-Base.html#t%3AErrorCall" >ErrorCall</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="Control-Exception-Base.html#t%3AErrorCall" >ErrorCall</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > <A HREF="Control-Exception-Base.html#t%3AErrorCall" >ErrorCall</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="2" ><A NAME="2" >Throwing exceptions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:throwIO" ><A NAME="v%3AthrowIO" ></A ></A ><B >throwIO</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" ><P >A variant of <TT ><A HREF="Control-Exception-Base.html#v%3Athrow" >throw</A ></TT > that can only be used within the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad. </P ><P >Although <TT ><A HREF="Control-Exception-Base.html#v%3AthrowIO" >throwIO</A ></TT > has a type that is an instance of the type of <TT ><A HREF="Control-Exception-Base.html#v%3Athrow" >throw</A ></TT >, the two functions are subtly different: </P ><PRE > throw e `seq` x ===> throw e throwIO e `seq` x ===> x </PRE ><P >The first example will cause the exception <TT >e</TT > to be raised, whereas the second one won't. In fact, <TT ><A HREF="Control-Exception-Base.html#v%3AthrowIO" >throwIO</A ></TT > will only cause an exception to be raised when it is used within the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad. The <TT ><A HREF="Control-Exception-Base.html#v%3AthrowIO" >throwIO</A ></TT > variant should be used in preference to <TT ><A HREF="Control-Exception-Base.html#v%3Athrow" >throw</A ></TT > to raise an exception within the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad because it guarantees ordering with respect to other <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > operations, whereas <TT ><A HREF="Control-Exception-Base.html#v%3Athrow" >throw</A ></TT > does not. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:throw" ><A NAME="v%3Athrow" ></A ></A ><B >throw</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => e -> a</TD ></TR ><TR ><TD CLASS="doc" >Throw an exception. Exceptions may be thrown from purely functional code, but may only be caught within the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:ioError" ><A NAME="v%3AioError" ></A ></A ><B >ioError</B > :: <A HREF="System-IO-Error.html#t%3AIOError" >IOError</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >Raise an <TT ><A HREF="System-IO-Error.html#t%3AIOError" >IOError</A ></TT > in the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:throwTo" ><A NAME="v%3AthrowTo" ></A ></A ><B >throwTo</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="Control-Concurrent.html#t%3AThreadId" >ThreadId</A > -> e -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P ><TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > raises an arbitrary exception in the target thread (GHC only). </P ><P ><TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > does not return until the exception has been raised in the target thread. The calling thread can thus be certain that the target thread has received the exception. This is a useful property to know when dealing with race conditions: eg. if there are two threads that can kill each other, it is guaranteed that only one of the threads will get to kill the other. </P ><P >Whatever work the target thread was doing when the exception was raised is not lost: the computation is suspended until required by another thread. </P ><P >If the target thread is currently making a foreign call, then the exception will not be raised (and hence <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > will not return) until the call has completed. This is the case regardless of whether the call is inside a <TT ><A HREF="Control-Exception-Base.html#v%3Ablock" >block</A ></TT > or not. </P ><P >Important note: the behaviour of <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > differs from that described in the paper "Asynchronous exceptions in Haskell" (<A HREF="http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm" >http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</A >). In the paper, <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > is non-blocking; but the library implementation adopts a more synchronous design in which <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > does not return until the exception is received by the target thread. The trade-off is discussed in Section 9 of the paper. Like any blocking operation, <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > is therefore interruptible (see Section 5.3 of the paper). </P ><P >There is no guarantee that the exception will be delivered promptly, although the runtime will endeavour to ensure that arbitrary delays don't occur. In GHC, an exception can only be raised when a thread reaches a <EM >safe point</EM >, where a safe point is where memory allocation occurs. Some loops do not perform any memory allocation inside the loop and therefore cannot be interrupted by a <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT >. </P ><P >Blocked <TT ><A HREF="Control-Exception-Base.html#v%3AthrowTo" >throwTo</A ></TT > is fair: if multiple threads are trying to throw an exception to the same target thread, they will succeed in FIFO order. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="3" ><A NAME="3" >Catching Exceptions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="4" ><A NAME="4" >The <TT >catch</TT > functions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:catch" ><A NAME="v%3Acatch" ></A ></A ><B >catch</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >The computation to run </TD ></TR ><TR ><TD CLASS="arg" >-> e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >Handler to invoke if an exception is raised </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example: </P ><PRE > catch (readFile f) (\e -> do let err = show (e :: IOException) hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err) return "") </PRE ><P >Note that we have to give a type signature to <TT >e</TT >, or the program will not typecheck as the type is ambiguous. While it is possible to catch exceptions of any type, see the previous section "Catching all exceptions" for an explanation of the problems with doing so. </P ><P >For catching exceptions in pure (non-<TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT >) expressions, see the function <TT ><A HREF="Control-Exception-Base.html#v%3Aevaluate" >evaluate</A ></TT >. </P ><P >Note that due to Haskell's unspecified evaluation order, an expression may throw one of several possible exceptions: consider the expression <TT >(error "urk") + (1 `div` 0)</TT >. Does the expression throw <TT >ErrorCall "urk"</TT >, or <TT >DivideByZero</TT >? </P ><P >The answer is "it might throw either"; the choice is non-deterministic. If you are catching any type of exception then you might catch either. If you are calling <TT >catch</TT > with type <TT >IO Int -> (ArithException -> IO Int) -> IO Int</TT > then the handler may get run with <TT >DivideByZero</TT > as an argument, or an <TT >ErrorCall "urk"</TT > exception may be propogated further up. If you call it again, you might get a the opposite behaviour. This is ok, because <TT ><A HREF="Control-Exception-Base.html#v%3Acatch" >catch</A ></TT > is an <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > computation. </P ><P >Note that the <A HREF="Prelude.html" >Prelude</A > also exports a function called Prelude.catch with a similar type to Control.Exception.catch, except that the <A HREF="Prelude.html" >Prelude</A > version only catches the IO and user families of exceptions (as required by Haskell 98). </P ><P >We recommend either hiding the <A HREF="Prelude.html" >Prelude</A > version of Prelude.catch when importing <A HREF="Control-Exception.html" >Control.Exception</A >: </P ><PRE > import Prelude hiding (catch) </PRE ><P >or importing <A HREF="Control-Exception.html" >Control.Exception</A > qualified, to avoid name-clashes: </P ><PRE > import qualified Control.Exception as C </PRE ><P >and then using <TT >C.catch</TT > </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:catchJust" ><A NAME="v%3AcatchJust" ></A ></A ><B >catchJust</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b</TD ><TD CLASS="rdoc" >Predicate to select exceptions </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >Computation to run </TD ></TR ><TR ><TD CLASS="arg" >-> b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >Handler </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >The function <TT ><A HREF="Control-Exception-Base.html#v%3AcatchJust" >catchJust</A ></TT > is like <TT ><A HREF="Control-Exception-Base.html#v%3Acatch" >catch</A ></TT >, but it takes an extra argument which is an <EM >exception predicate</EM >, a function which selects which type of exceptions we're interested in. </P ><PRE > catchJust (\e -> if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing) (readFile f) (\_ -> do hPutStrLn stderr ("No such file: " ++ show f) return "") </PRE ><P >Any other exceptions which are not matched by the predicate are re-raised, and may be caught by an enclosing <TT ><A HREF="Control-Exception-Base.html#v%3Acatch" >catch</A ></TT >, <TT ><A HREF="Control-Exception-Base.html#v%3AcatchJust" >catchJust</A ></TT >, etc. </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="5" ><A NAME="5" >The <TT >handle</TT > functions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:handle" ><A NAME="v%3Ahandle" ></A ></A ><B >handle</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" ><P >A version of <TT ><A HREF="Control-Exception-Base.html#v%3Acatch" >catch</A ></TT > with the arguments swapped around; useful in situations where the code for the handler is shorter. For example: </P ><PRE > do handle (\NonTermination -> exitWith (ExitFailure 1)) $ ... </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:handleJust" ><A NAME="v%3AhandleJust" ></A ></A ><B >handleJust</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> (b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >A version of <TT ><A HREF="Control-Exception-Base.html#v%3AcatchJust" >catchJust</A ></TT > with the arguments swapped around (see <TT ><A HREF="Control-Exception-Base.html#v%3Ahandle" >handle</A ></TT >). </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="6" ><A NAME="6" >The <TT >try</TT > functions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:try" ><A NAME="v%3Atry" ></A ></A ><B >try</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Either.html#t%3AEither" >Either</A > e a)</TD ></TR ><TR ><TD CLASS="doc" ><P >Similar to <TT ><A HREF="Control-Exception-Base.html#v%3Acatch" >catch</A ></TT >, but returns an <TT ><A HREF="Data-Either.html#t%3AEither" >Either</A ></TT > result which is <TT >(<TT ><A HREF="Data-Either.html#v%3ARight" >Right</A ></TT > a)</TT > if no exception of type <TT >e</TT > was raised, or <TT >(<TT ><A HREF="Data-Either.html#v%3ALeft" >Left</A ></TT > ex)</TT > if an exception of type <TT >e</TT > was raised and its value is <TT >ex</TT >. If any other type of exception is raised than it will be propogated up to the next enclosing exception handler. </P ><PRE > try a = catch (Right `liftM` a) (return . Left) </PRE ><P >Note that <A HREF="System-IO-Error.html" >System.IO.Error</A > also exports a function called System.IO.Error.try with a similar type to Control.Exception.try, except that it catches only the IO and user families of exceptions (as required by the Haskell 98 <TT >IO</TT > module). </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:tryJust" ><A NAME="v%3AtryJust" ></A ></A ><B >tryJust</B > :: <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e => (e -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Either.html#t%3AEither" >Either</A > b a)</TD ></TR ><TR ><TD CLASS="doc" >A variant of <TT ><A HREF="Control-Exception-Base.html#v%3Atry" >try</A ></TT > that takes an exception predicate to select which exceptions are caught (c.f. <TT ><A HREF="Control-Exception-Base.html#v%3AcatchJust" >catchJust</A ></TT >). If the exception does not match the predicate, it is re-thrown. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:onException" ><A NAME="v%3AonException" ></A ></A ><B >onException</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >Like <TT ><A HREF="Control-Exception-Base.html#v%3Afinally" >finally</A ></TT >, but only performs the final action if there was an exception raised by the computation. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="7" ><A NAME="7" >The <TT >evaluate</TT > function </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:evaluate" ><A NAME="v%3Aevaluate" ></A ></A ><B >evaluate</B > :: a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" ><P >Forces its argument to be evaluated to weak head normal form when the resultant <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > action is executed. It can be used to order evaluation with respect to other <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > operations; its semantics are given by </P ><PRE > evaluate x `seq` y ==> y evaluate x `catch` f ==> (return $! x) `catch` f evaluate x >>= f ==> (return $! x) >>= f </PRE ><P ><EM >Note:</EM > the first equation implies that <TT >(evaluate x)</TT > is <EM >not</EM > the same as <TT >(return $! x)</TT >. A correct definition is </P ><PRE > evaluate x = (return $! x) >>= return </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="8" ><A NAME="8" >The <TT >mapException</TT > function </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:mapException" ><A NAME="v%3AmapException" ></A ></A ><B >mapException</B > :: (<A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e1, <A HREF="Control-Exception-Base.html#t%3AException" >Exception</A > e2) => (e1 -> e2) -> a -> a</TD ></TR ><TR ><TD CLASS="doc" >This function maps one exception into another as proposed in the paper "A semantics for imprecise exceptions". </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="9" ><A NAME="9" >Asynchronous Exceptions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="10" ><A NAME="10" >Asynchronous exception control </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:block" ><A NAME="v%3Ablock" ></A ></A ><B >block</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" ><P >Applying <TT ><A HREF="Control-Exception-Base.html#v%3Ablock" >block</A ></TT > to a computation will execute that computation with asynchronous exceptions <EM >blocked</EM >. That is, any thread which attempts to raise an exception in the current thread with Control.Exception.throwTo will be blocked until asynchronous exceptions are enabled again. There's no need to worry about re-enabling asynchronous exceptions; that is done automatically on exiting the scope of <TT ><A HREF="Control-Exception-Base.html#v%3Ablock" >block</A ></TT >. </P ><P >Threads created by Control.Concurrent.forkIO inherit the blocked state from the parent; that is, to start a thread in blocked mode, use <TT >block $ forkIO ...</TT >. This is particularly useful if you need to establish an exception handler in the forked thread before any asynchronous exceptions are received. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:unblock" ><A NAME="v%3Aunblock" ></A ></A ><B >unblock</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >To re-enable asynchronous exceptions inside the scope of <TT ><A HREF="Control-Exception-Base.html#v%3Ablock" >block</A ></TT >, <TT ><A HREF="Control-Exception-Base.html#v%3Aunblock" >unblock</A ></TT > can be used. It scopes in exactly the same way, so on exit from <TT ><A HREF="Control-Exception-Base.html#v%3Aunblock" >unblock</A ></TT > asynchronous exception delivery will be disabled again. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:blocked" ><A NAME="v%3Ablocked" ></A ></A ><B >blocked</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" >returns True if asynchronous exceptions are blocked in the current thread. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="11" ><A NAME="11" >Assertions </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:assert" ><A NAME="v%3Aassert" ></A ></A ><B >assert</B > :: <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> a -> a</TD ></TR ><TR ><TD CLASS="doc" ><P >If the first argument evaluates to <TT ><A HREF="Data-Bool.html#v%3ATrue" >True</A ></TT >, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a <TT ><A HREF="Data-Char.html#t%3AString" >String</A ></TT > with the source file and line number of the call to <TT ><A HREF="Control-Exception-Base.html#v%3Aassert" >assert</A ></TT >. </P ><P >Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with <TT >-O</TT > or the <TT >-fignore-asserts</TT > option is given). When assertions are turned off, the first argument to <TT ><A HREF="Control-Exception-Base.html#v%3Aassert" >assert</A ></TT > is ignored, and the second argument is returned as the result. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="12" ><A NAME="12" >Utilities </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:bracket" ><A NAME="v%3Abracket" ></A ></A ><B >bracket</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >computation to run first ("acquire resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b</TD ><TD CLASS="rdoc" >computation to run last ("release resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ><TD CLASS="rdoc" >computation to run in-between </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT >, because <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > will re-raise the exception (after performing the release). </P ><P >A common example is opening a file: </P ><PRE > bracket (openFile "filename" ReadMode) (hClose) (\fileHandle -> do { ... }) </PRE ><P >The arguments to <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > are in this order so that we can partially apply it, e.g.: </P ><PRE > withFile name mode = bracket (openFile name mode) hClose </PRE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:bracket_" ><A NAME="v%3Abracket_" ></A ></A ><B >bracket_</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b -> <A HREF="System-IO.html#t%3AIO" >IO</A > c -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ></TR ><TR ><TD CLASS="doc" >A variant of <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > where the return value from the first computation is not required. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:bracketOnError" ><A NAME="v%3AbracketOnError" ></A ></A ><B >bracketOnError</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >computation to run first ("acquire resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> <A HREF="System-IO.html#t%3AIO" >IO</A > b</TD ><TD CLASS="rdoc" >computation to run last ("release resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ><TD CLASS="rdoc" >computation to run in-between </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > c</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >Like <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT >, but only performs the final action if there was an exception raised by the in-between computation. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:finally" ><A NAME="v%3Afinally" ></A ></A ><B >finally</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" >computation to run first </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > b</TD ><TD CLASS="rdoc" >computation to run afterward (even if an exception was raised) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >A specialised variant of <TT ><A HREF="Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > with just a computation to run afterward. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="13" ><A NAME="13" >Calls for GHC runtime </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:recSelError" ><A NAME="v%3ArecSelError" ></A ></A ><B >recSelError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:recConError" ><A NAME="v%3ArecConError" ></A ></A ><B >recConError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:irrefutPatError" ><A NAME="v%3AirrefutPatError" ></A ></A ><B >irrefutPatError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:runtimeError" ><A NAME="v%3AruntimeError" ></A ></A ><B >runtimeError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:nonExhaustiveGuardsError" ><A NAME="v%3AnonExhaustiveGuardsError" ></A ></A ><B >nonExhaustiveGuardsError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:patError" ><A NAME="v%3ApatError" ></A ></A ><B >patError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:noMethodBindingError" ><A NAME="v%3AnoMethodBindingError" ></A ></A ><B >noMethodBindingError</B > :: <A HREF="../ghc-prim-0.2.0.0/GHC-Prim.html#t%3AAddr%23" >Addr#</A > -> a</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:nonTermination" ><A NAME="v%3AnonTermination" ></A ></A ><B >nonTermination</B > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:nestedAtomically" ><A NAME="v%3AnestedAtomically" ></A ></A ><B >nestedAtomically</B > :: <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></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.6.1</TD ></TR ></TABLE ></BODY ></HTML >