<!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 >System.Exit</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_System-Exit.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" >System.Exit</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >provisional</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >Exiting the program. </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%3AExitCode" >ExitCode</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AExitSuccess" >ExitSuccess</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AExitFailure" >ExitFailure</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AexitWith" >exitWith</A > :: <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</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%3AexitFailure" >exitFailure</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%3AexitSuccess" >exitSuccess</A > :: <A HREF="System-IO.html#t%3AIO" >IO</A > 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:ExitCode" ><A NAME="t%3AExitCode" ></A ></A ><B >ExitCode</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:ExitSuccess" ><A NAME="v%3AExitSuccess" ></A ></A ><B >ExitSuccess</B ></TD ><TD CLASS="rdoc" >indicates successful termination; </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:ExitFailure" ><A NAME="v%3AExitFailure" ></A ></A ><B >ExitFailure</B > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ><TD CLASS="rdoc" >indicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system). </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ExitCode')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:ExitCode" 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="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</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="System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:exitWith" ><A NAME="v%3AexitWith" ></A ></A ><B >exitWith</B > :: <A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > <TT >code</TT > throws <TT ><A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TT > <TT >code</TT >. Normally this terminates the program, returning <TT >code</TT > to the program's caller. Before the program terminates, any open or semi-closed handles are first closed. </P ><P >A program that fails in any other way is treated as if it had called <TT ><A HREF="System-Exit.html#v%3AexitFailure" >exitFailure</A ></TT >. A program that terminates successfully without calling <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > explicitly is treated as it it had called <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > <TT ><A HREF="System-Exit.html#v%3AExitSuccess" >ExitSuccess</A ></TT >. </P ><P >As an <TT ><A HREF="System-Exit.html#t%3AExitCode" >ExitCode</A ></TT > is not an <TT ><A HREF="System-IO-Error.html#t%3AIOError" >IOError</A ></TT >, <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > bypasses the error handling in the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad and cannot be intercepted by <TT ><A HREF="System-IO-Error.html#v%3Acatch" >catch</A ></TT > from the <A HREF="Prelude.html" >Prelude</A >. However it is a SomeException, and can be caught using the functions of <A HREF="Control-Exception.html" >Control.Exception</A >. This means that cleanup computations added with Control.Exception.bracket (from <A HREF="Control-Exception.html" >Control.Exception</A >) are also executed properly on <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT >. </P ><P >Note: in GHC, <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > should be called from the main program thread in order to exit the process. When called from another thread, <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > will throw an ExitException as normal, but the exception will not cause the process itself to exit. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:exitFailure" ><A NAME="v%3AexitFailure" ></A ></A ><B >exitFailure</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >The computation <TT ><A HREF="System-Exit.html#v%3AexitFailure" >exitFailure</A ></TT > is equivalent to <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > <TT >(</TT ><TT ><A HREF="System-Exit.html#v%3AExitFailure" >ExitFailure</A ></TT > <EM >exitfail</EM ><TT >)</TT >, where <EM >exitfail</EM > is implementation-dependent. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:exitSuccess" ><A NAME="v%3AexitSuccess" ></A ></A ><B >exitSuccess</B > :: <A HREF="System-IO.html#t%3AIO" >IO</A > a</TD ></TR ><TR ><TD CLASS="doc" >The computation <TT ><A HREF="System-Exit.html#v%3AexitSuccess" >exitSuccess</A ></TT > is equivalent to <TT ><A HREF="System-Exit.html#v%3AexitWith" >exitWith</A ></TT > <TT ><A HREF="System-Exit.html#v%3AExitSuccess" >ExitSuccess</A ></TT >, It terminates the program sucessfully. </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 >