<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >Control.Monad.CatchIO</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_Control-Monad-CatchIO.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" >MonadCatchIO-mtl-0.3.0.4: Monad-transformer version of the Control.Exception module</TD ><TD CLASS="topbut" ><A HREF="src/Control-Monad-CatchIO.html" >Source code</A ></TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >Control.Monad.CatchIO</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" ><SPAN CLASS="keyword" >class</SPAN > <A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Trans.html#t%3AMonadIO" >MonadIO</A > m => <A HREF="#t%3AMonadCatchIO" >MonadCatchIO</A > m <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%3Acatch" >catch</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e => m a -> (e -> m a) -> m a</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Ablock" >block</A > :: m a -> m a</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aunblock" >unblock</A > :: m a -> m a</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >class</SPAN > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Typeable.html#t%3ATypeable" >Typeable</A > e, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/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="/usr/share/doc/ghc/html/libraries/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="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException" >SomeException</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/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%3Athrow" >throw</A > :: (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Trans.html#t%3AMonadIO" >MonadIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => e -> m a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Atry" >try</A > :: (<A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => m a -> m (<A HREF="/usr/share/doc/ghc/html/libraries/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%3AtryJust" >tryJust</A > :: (<A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => (e -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> m a -> m (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/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="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> m b -> m a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Abracket" >bracket</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> (a -> m b) -> (a -> m c) -> m c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Abracket_" >bracket_</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> m b -> m c -> m c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Afinally" >finally</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> m b -> m a</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AbracketOnError" >bracketOnError</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> (a -> m b) -> (a -> m c) -> m c</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AHandler" >Handler</A > m a = <SPAN CLASS="keyword" >forall</SPAN > e . <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e => <A HREF="#v%3AHandler" >Handler</A > (e -> m a)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Acatches" >catches</A > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> [<A HREF="Control-Monad-CatchIO.html#t%3AHandler" >Handler</A > m a] -> m 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="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><SPAN CLASS="keyword" >class</SPAN > <A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Trans.html#t%3AMonadIO" >MonadIO</A > m => <A NAME="t:MonadCatchIO" ><A NAME="t%3AMonadCatchIO" ></A ></A ><B >MonadCatchIO</B > m <SPAN CLASS="keyword" >where</SPAN ></TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#MonadCatchIO" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="section4" >Methods</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:catch" ><A NAME="v%3Acatch" ></A ></A ><B >catch</B > :: <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e => m a -> (e -> m a) -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#catch" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3Acatch" >catch</A ></TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:block" ><A NAME="v%3Ablock" ></A ></A ><B >block</B > :: m a -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#block" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3Ablock" >block</A ></TT > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:unblock" ><A NAME="v%3Aunblock" ></A ></A ><B >unblock</B > :: m a -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#unblock" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3Aunblock" >unblock</A ></TT > </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:MonadCatchIO')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:MonadCatchIO" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/System-IO.html#t%3AIO" >IO</A ></TD ></TR ><TR ><TD CLASS="decl" >(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Monoid.html#t%3AMonoid" >Monoid</A > w, <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m) => <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Writer-Lazy.html#t%3AWriterT" >WriterT</A > w m)</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-State-Lazy.html#t%3AStateT" >StateT</A > s m)</TD ></TR ><TR ><TD CLASS="decl" >(<A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m, <A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Error-Class.html#t%3AError" >Error</A > e) => <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Error.html#t%3AErrorT" >ErrorT</A > e m)</TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Reader.html#t%3AReaderT" >ReaderT</A > r m)</TD ></TR ><TR ><TD CLASS="decl" >(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Monoid.html#t%3AMonoid" >Monoid</A > w, <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m) => <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-RWS-Lazy.html#t%3ARWST" >RWST</A > r w s m)</TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><SPAN CLASS="keyword" >class</SPAN > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Typeable.html#t%3ATypeable" >Typeable</A > e, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/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 ><TD CLASS="declbut" ><A HREF="src/GHC-Exception.html#Exception" >Source</A ></TD ></TR ></TABLE ></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> throw ThisException catch e -> putStrLn ("Caught " ++ 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 => 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 </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> 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 </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="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:toException" ><A NAME="v%3AtoException" ></A ></A ><B >toException</B > :: e -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ><TD CLASS="declbut" ><A HREF="src/GHC-Exception.html#toException" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:fromException" ><A NAME="v%3AfromException" ></A ></A ><B >fromException</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException" >SomeException</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Maybe.html#t%3AMaybe" >Maybe</A > e</TD ><TD CLASS="declbut" ><A HREF="src/GHC-Exception.html#fromException" >Source</A ></TD ></TR ></TABLE ></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-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3APatternMatchFail" >PatternMatchFail</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ARecSelError" >RecSelError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ARecConError" >RecConError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ARecUpdError" >RecUpdError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ANoMethodError" >NoMethodError</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ANonTermination" >NonTermination</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ANestedAtomically" >NestedAtomically</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3ASomeException" >SomeException</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#t%3AErrorCall" >ErrorCall</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/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="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:throw" ><A NAME="v%3Athrow" ></A ></A ><B >throw</B > :: (<A HREF="/usr/share/doc/ghc/html/libraries/mtl-1.1.0.2/Control-Monad-Trans.html#t%3AMonadIO" >MonadIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => e -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#throw" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3AthrowIO" >throwIO</A ></TT > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:try" ><A NAME="v%3Atry" ></A ></A ><B >try</B > :: (<A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => m a -> m (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Either.html#t%3AEither" >Either</A > e a)</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#try" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3Atry" >try</A ></TT > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:tryJust" ><A NAME="v%3AtryJust" ></A ></A ><B >tryJust</B > :: (<A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m, <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e) => (e -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Maybe.html#t%3AMaybe" >Maybe</A > b) -> m a -> m (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Either.html#t%3AEither" >Either</A > b a)</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#tryJust" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3AtryJust" >tryJust</A ></TT > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:onException" ><A NAME="v%3AonException" ></A ></A ><B >onException</B > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> m b -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#onException" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3AonException" >onException</A ></TT > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:bracket" ><A NAME="v%3Abracket" ></A ></A ><B >bracket</B > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> (a -> m b) -> (a -> m c) -> m c</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#bracket" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception-Base.html#v%3Abracket" >bracket</A ></TT > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:bracket_" ><A NAME="v%3Abracket_" ></A ></A ><B >bracket_</B ></TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#bracket_" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> m a</TD ><TD CLASS="rdoc" >computation to run first ("acquire resource") </TD ></TR ><TR ><TD CLASS="arg" >-> m b</TD ><TD CLASS="rdoc" >computation to run last ("release resource") </TD ></TR ><TR ><TD CLASS="arg" >-> m c</TD ><TD CLASS="rdoc" >computation to run in-between </TD ></TR ><TR ><TD CLASS="arg" >-> m c</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >A variant of <TT ><A HREF="Control-Monad-CatchIO.html#v%3Abracket" >bracket</A ></TT > where the return value from the first computation is not required. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:finally" ><A NAME="v%3Afinally" ></A ></A ><B >finally</B ></TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#finally" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> m a</TD ><TD CLASS="rdoc" >computation to run first </TD ></TR ><TR ><TD CLASS="arg" >-> m b</TD ><TD CLASS="rdoc" >computation to run afterward (even if an exception was raised) </TD ></TR ><TR ><TD CLASS="arg" >-> m a</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >A specialised variant of <TT ><A HREF="Control-Monad-CatchIO.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="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:bracketOnError" ><A NAME="v%3AbracketOnError" ></A ></A ><B >bracketOnError</B ></TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#bracketOnError" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> m a</TD ><TD CLASS="rdoc" >computation to run first ("acquire resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> m b</TD ><TD CLASS="rdoc" >computation to run last ("release resource") </TD ></TR ><TR ><TD CLASS="arg" >-> a -> m c</TD ><TD CLASS="rdoc" >computation to run in-between </TD ></TR ><TR ><TD CLASS="arg" >-> m c</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >Like <TT ><A HREF="Control-Monad-CatchIO.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="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Handler" ><A NAME="t%3AHandler" ></A ></A ><B >Handler</B > m a </TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#Handler" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception.html#t%3AHandler" >Handler</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" ><SPAN CLASS="keyword" >forall</SPAN > e . <A HREF="Control-Monad-CatchIO.html#t%3AException" >Exception</A > e => <A NAME="v:Handler" ><A NAME="v%3AHandler" ></A ></A ><B >Handler</B > (e -> m a)</TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="topdecl" ><TABLE CLASS="declbar" ><TR ><TD CLASS="declname" ><A NAME="v:catches" ><A NAME="v%3Acatches" ></A ></A ><B >catches</B > :: <A HREF="Control-Monad-CatchIO.html#t%3AMonadCatchIO" >MonadCatchIO</A > m => m a -> [<A HREF="Control-Monad-CatchIO.html#t%3AHandler" >Handler</A > m a] -> m a</TD ><TD CLASS="declbut" ><A HREF="src/Control-Monad-CatchIO.html#catches" >Source</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="doc" >Generalized version of <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Exception.html#v%3Acatches" >catches</A ></TT > </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 >