Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > da2ed07af0cf0f424d74f4cc6829a27c > files > 1027

ghc-ghc-devel-6.12.3-8.6.fc14.i686.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
>Panic</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_Panic.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"
>ghc-6.12.3: The GHC API</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"
>Panic</FONT
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></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"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A HREF="#t%3AGhcException"
>GhcException</A
>  </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
>= <A HREF="#v%3APhaseFailed"
>PhaseFailed</A
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> <A HREF="../base-4.2.0.2/System-Exit.html#t%3AExitCode"
>ExitCode</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3AInterrupted"
>Interrupted</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3ASignal"
>Signal</A
> <A HREF="../base-4.2.0.2/Data-Int.html#t%3AInt"
>Int</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3AUsageError"
>UsageError</A
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3ACmdLineError"
>CmdLineError</A
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3APanic"
>Panic</A
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3AInstallationError"
>InstallationError</A
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="decl"
>| <A HREF="#v%3AProgramError"
>ProgramError</A
> <A HREF="../base-4.2.0.2/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"
><A HREF="#v%3AshowGhcException"
>showGhcException</A
> :: <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AthrowGhcException"
>throwGhcException</A
> ::  <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AhandleGhcException"
>handleGhcException</A
> :: <A HREF="Exception.html#t%3AExceptionMonad"
>ExceptionMonad</A
> m =&gt; (<A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; m a) -&gt; m a -&gt; m a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AghcError"
>ghcError</A
> ::  <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AprogName"
>progName</A
> :: <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ApgmError"
>pgmError</A
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Apanic"
>panic</A
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ApanicFastInt"
>panicFastInt</A
> :: <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="FastTypes.html#t%3AFastInt"
>FastInt</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AassertPanic"
>assertPanic</A
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Int.html#t%3AInt"
>Int</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Atrace"
>trace</A
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>class</SPAN
> (<A HREF="../base-4.2.0.2/Data-Typeable.html#t%3ATypeable"
>Typeable</A
> e, <A HREF="../base-4.2.0.2/Text-Show.html#t%3AShow"
>Show</A
> e) =&gt; <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 -&gt; <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfromException"
>fromException</A
> :: <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Maybe.html#t%3AMaybe"
>Maybe</A
> e</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AshowException"
>showException</A
> :: <A HREF="Panic.html#t%3AException"
>Exception</A
> e =&gt; e -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Atry"
>try</A
> :: <A HREF="Panic.html#t%3AException"
>Exception</A
> e =&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="../base-4.2.0.2/Data-Either.html#t%3AEither"
>Either</A
> e a)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AtryMost"
>tryMost</A
> ::  <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="../base-4.2.0.2/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
> a)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AthrowTo"
>throwTo</A
> :: <A HREF="Panic.html#t%3AException"
>Exception</A
> e =&gt; <A HREF="../base-4.2.0.2/Control-Concurrent.html#t%3AThreadId"
>ThreadId</A
> -&gt; e -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> ()</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AinstallSignalHandlers"
>installSignalHandlers</A
> :: <A HREF="../base-4.2.0.2/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%3AinterruptTargetThread"
>interruptTargetThread</A
> :: <A HREF="../base-4.2.0.2/Control-Concurrent-MVar.html#t%3AMVar"
>MVar</A
> [<A HREF="../base-4.2.0.2/Control-Concurrent.html#t%3AThreadId"
>ThreadId</A
>]</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"
>data</SPAN
>  <A NAME="t:GhcException"
><A NAME="t%3AGhcException"
></A
></A
><B
>GhcException</B
>  </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><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:PhaseFailed"
><A NAME="v%3APhaseFailed"
></A
></A
><B
>PhaseFailed</B
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> <A HREF="../base-4.2.0.2/System-Exit.html#t%3AExitCode"
>ExitCode</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:Interrupted"
><A NAME="v%3AInterrupted"
></A
></A
><B
>Interrupted</B
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:Signal"
><A NAME="v%3ASignal"
></A
></A
><B
>Signal</B
> <A HREF="../base-4.2.0.2/Data-Int.html#t%3AInt"
>Int</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:UsageError"
><A NAME="v%3AUsageError"
></A
></A
><B
>UsageError</B
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:CmdLineError"
><A NAME="v%3ACmdLineError"
></A
></A
><B
>CmdLineError</B
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:Panic"
><A NAME="v%3APanic"
></A
></A
><B
>Panic</B
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:InstallationError"
><A NAME="v%3AInstallationError"
></A
></A
><B
>InstallationError</B
> <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
><A NAME="v:ProgramError"
><A NAME="v%3AProgramError"
></A
></A
><B
>ProgramError</B
> <A HREF="../base-4.2.0.2/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:GhcException')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:GhcException" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="../base-4.2.0.2/Data-Eq.html#t%3AEq"
>Eq</A
> <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="../base-4.2.0.2/Text-Show.html#t%3AShow"
>Show</A
> <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="../base-4.2.0.2/Data-Typeable.html#t%3ATypeable"
>Typeable</A
> <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:showGhcException"
><A NAME="v%3AshowGhcException"
></A
></A
><B
>showGhcException</B
> :: <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:throwGhcException"
><A NAME="v%3AthrowGhcException"
></A
></A
><B
>throwGhcException</B
> ::  <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:handleGhcException"
><A NAME="v%3AhandleGhcException"
></A
></A
><B
>handleGhcException</B
> :: <A HREF="Exception.html#t%3AExceptionMonad"
>ExceptionMonad</A
> m =&gt; (<A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; m a) -&gt; m a -&gt; m a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:ghcError"
><A NAME="v%3AghcError"
></A
></A
><B
>ghcError</B
> ::  <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:progName"
><A NAME="v%3AprogName"
></A
></A
><B
>progName</B
> :: <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:pgmError"
><A NAME="v%3ApgmError"
></A
></A
><B
>pgmError</B
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:panic"
><A NAME="v%3Apanic"
></A
></A
><B
>panic</B
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:panicFastInt"
><A NAME="v%3ApanicFastInt"
></A
></A
><B
>panicFastInt</B
> :: <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="FastTypes.html#t%3AFastInt"
>FastInt</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:assertPanic"
><A NAME="v%3AassertPanic"
></A
></A
><B
>assertPanic</B
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="../base-4.2.0.2/Data-Int.html#t%3AInt"
>Int</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:trace"
><A NAME="v%3Atrace"
></A
></A
><B
>trace</B
> ::  <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</A
> -&gt; a -&gt; a</TD
></TR
><TR
><TD CLASS="doc"
>When called, <TT
><A HREF="Panic.html#v%3Atrace"
>trace</A
></TT
> outputs the string in its first argument, before 
returning the second argument as its result. The <TT
><A HREF="Panic.html#v%3Atrace"
>trace</A
></TT
> function is not 
referentially transparent, and should only be used for debugging, or for 
monitoring execution. Some implementations of <TT
><A HREF="Panic.html#v%3Atrace"
>trace</A
></TT
> may decorate the string 
that's output to indicate that you're tracing. The function is implemented on
top of <TT
><A HREF="../base-4.2.0.2/Debug-Trace.html#v%3AputTraceMsg"
>putTraceMsg</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>class</SPAN
> (<A HREF="../base-4.2.0.2/Data-Typeable.html#t%3ATypeable"
>Typeable</A
> e, <A HREF="../base-4.2.0.2/Text-Show.html#t%3AShow"
>Show</A
> e) =&gt; <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
><TT
> data MyException = ThisException | ThatException
     deriving (Show, Typeable)

 instance Exception MyException
</TT
><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
><TT
>
*Main&gt; throw ThisException catch e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: MyException))
Caught ThisException
</TT
><P
>In more complicated examples, you may wish to define a whole hierarchy
of exceptions:
</P
><TT
> ---------------------------------------------------------------------
 -- Make the root exception type for all the exceptions in a compiler

 data SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
     deriving Typeable

 instance Show SomeCompilerException where
     show (SomeCompilerException e) = show e

 instance Exception SomeCompilerException

 compilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
 compilerExceptionToException = toException . SomeCompilerException

 compilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
 compilerExceptionFromException x = do
     SomeCompilerException a &lt;- fromException x
     cast a

 ---------------------------------------------------------------------
 -- Make a subhierarchy for exceptions in the frontend of the compiler

 data SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
     deriving Typeable

 instance Show SomeFrontendException where
     show (SomeFrontendException e) = show e

 instance Exception SomeFrontendException where
     toException = compilerExceptionToException
     fromException = compilerExceptionFromException

 frontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
 frontendExceptionToException = toException . SomeFrontendException

 frontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
 frontendExceptionFromException x = do
     SomeFrontendException a &lt;- 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
</TT
><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
><TT
>
*Main&gt; throw MismatchedParentheses catch e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses catch e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses catch e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses catch e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: IOException))
*** Exception: MismatchedParentheses
</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:toException"
><A NAME="v%3AtoException"
></A
></A
><B
>toException</B
> :: e -&gt; <A HREF="../base-4.2.0.2/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="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
> -&gt; <A HREF="../base-4.2.0.2/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="Panic.html#t%3AException"
>Exception</A
> BlockedOnDeadMVar</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> BlockedIndefinitely</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3APatternMatchFail"
>PatternMatchFail</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ARecSelError"
>RecSelError</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ARecConError"
>RecConError</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ARecUpdError"
>RecUpdError</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ANoMethodError"
>NoMethodError</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ANonTermination"
>NonTermination</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ANestedAtomically"
>NestedAtomically</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ABlockedIndefinitelyOnMVar"
>BlockedIndefinitelyOnMVar</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ABlockedIndefinitelyOnSTM"
>BlockedIndefinitelyOnSTM</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ADeadlock"
>Deadlock</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AAssertionFailed"
>AssertionFailed</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AAsyncException"
>AsyncException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AArrayException"
>ArrayException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/System-Exit.html#t%3AExitCode"
>ExitCode</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Data-Dynamic.html#t%3ADynamic"
>Dynamic</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AIOException"
>IOException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AErrorCall"
>ErrorCall</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3AArithException"
>ArithException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="Panic.html#t%3AGhcException"
>GhcException</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="IOEnv.html#t%3AIOEnvFailure"
>IOEnvFailure</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="HscTypes.html#t%3AGhcApiError"
>GhcApiError</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Panic.html#t%3AException"
>Exception</A
> <A HREF="HscTypes.html#t%3ASourceError"
>SourceError</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:showException"
><A NAME="v%3AshowException"
></A
></A
><B
>showException</B
> :: <A HREF="Panic.html#t%3AException"
>Exception</A
> e =&gt; e -&gt; <A HREF="../base-4.2.0.2/Data-Char.html#t%3AString"
>String</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="Panic.html#t%3AException"
>Exception</A
> e =&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="../base-4.2.0.2/Data-Either.html#t%3AEither"
>Either</A
> e a)</TD
></TR
><TR
><TD CLASS="doc"
><P
>Similar to <TT
><A HREF="../base-4.2.0.2/Control-Exception-Base.html#v%3Acatch"
>catch</A
></TT
>, but returns an <TT
><A HREF="../base-4.2.0.2/Data-Either.html#t%3AEither"
>Either</A
></TT
> result which is
 <TT
>(<TT
><A HREF="../base-4.2.0.2/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="../base-4.2.0.2/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
><TT
>  try a = catch (Right `liftM` a) (return . Left)
</TT
><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:tryMost"
><A NAME="v%3AtryMost"
></A
></A
><B
>tryMost</B
> ::  <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="../base-4.2.0.2/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="../base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException"
>SomeException</A
> a)</TD
></TR
><TR
><TD CLASS="doc"
>tryMost is like try, but passes through Interrupted and Panic
 exceptions.  Used when we want soft failures when reading interface
 files, for example.
</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="Panic.html#t%3AException"
>Exception</A
> e =&gt; <A HREF="../base-4.2.0.2/Control-Concurrent.html#t%3AThreadId"
>ThreadId</A
> -&gt; e -&gt; <A HREF="../base-4.2.0.2/System-IO.html#t%3AIO"
>IO</A
> ()</TD
></TR
><TR
><TD CLASS="doc"
><P
><TT
><A HREF="Panic.html#v%3AthrowTo"
>throwTo</A
></TT
> raises an arbitrary exception in the target thread (GHC only).
</P
><P
><TT
><A HREF="Panic.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="Panic.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="../base-4.2.0.2/Control-Exception-Base.html#v%3Ablock"
>block</A
></TT
> or not.
</P
><P
>Important note: the behaviour of <TT
><A HREF="Panic.html#v%3AthrowTo"
>throwTo</A
></TT
> differs from that described in
the paper &quot;Asynchronous exceptions in Haskell&quot;
(<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="Panic.html#v%3AthrowTo"
>throwTo</A
></TT
> is non-blocking; but the library implementation adopts
a more synchronous design in which <TT
><A HREF="Panic.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="Panic.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="Panic.html#v%3AthrowTo"
>throwTo</A
></TT
>.
</P
><P
>Blocked <TT
><A HREF="Panic.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="decl"
><A NAME="v:installSignalHandlers"
><A NAME="v%3AinstallSignalHandlers"
></A
></A
><B
>installSignalHandlers</B
> :: <A HREF="../base-4.2.0.2/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="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:interruptTargetThread"
><A NAME="v%3AinterruptTargetThread"
></A
></A
><B
>interruptTargetThread</B
> :: <A HREF="../base-4.2.0.2/Control-Concurrent-MVar.html#t%3AMVar"
>MVar</A
> [<A HREF="../base-4.2.0.2/Control-Concurrent.html#t%3AThreadId"
>ThreadId</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
>