Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > eed130d744d27f25ed585ff318f1f4e2 > files > 10

ocaml-pa-monad-6.0-10.fc18.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="pa_monad.html">
<link rel="previous" href="Cc.html">
<link rel="next" href="Io.html">
<link rel="Up" href="pa_monad.html">
<link title="Index of types" rel=Appendix href="pa_monad_types.html">
<link title="Index of exceptions" rel=Appendix href="pa_monad_exceptions.html">
<link title="Index of values" rel=Appendix href="pa_monad_values.html">
<link title="Index of modules" rel=Appendix href="pa_monad_modules.html">
<link title="Pa_monad" rel="Chapter" href="Pa_monad.html">
<link title="Cc" rel="Chapter" href="Cc.html">
<link title="Exception" rel="Chapter" href="Exception.html">
<link title="Io" rel="Chapter" href="Io.html">
<link title="Utest" rel="Chapter" href="Utest.html"><title>Exception</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Cc.html" title="Cc">Previous</a>
&nbsp;<a class="up" href="pa_monad.html" title="Index">Up</a>
&nbsp;<a class="post" href="Io.html" title="Io">Next</a>
</div>
<h1>Module <a href="type_Exception.html">Exception</a></h1>
<pre><span class="keyword">module</span> Exception: <code class="code">sig</code> <a href="Exception.html">..</a> <code class="code">end</code></pre><div class="info">
Exception is a purely functional replacement of
    OCaml's built-in exceptions.
<p>

    To indicate a normal value use <a href="Exception.html#VALreturn"><code class="code">Exception.return</code></a>.  For
    exceptional conditions use <a href="Exception.html#VALthrow"><code class="code">Exception.throw</code></a>.  Function
    <a href="Exception.html#VALcatch"><code class="code">Exception.catch</code></a> splices in an exception handler into the
    thread of control.  Execute an exception monad with
    <a href="Exception.html#VALrun"><code class="code">Exception.run</code></a>.<br>
</div>
<hr width="100%">
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">('left, 'right)</code> t</span> </pre>
<div class="info">
Type of an exception monad.  <code class="code">'left</code> is the exception's type and
    <code class="code">'right</code> is the normal value's type.<br>
</div>

<pre><span id="VALbind"><span class="keyword">val</span> bind</span> : <code class="type">('left, 'right) <a href="Exception.html#TYPEt">t</a> -><br>       ('right -> ('left, 'new_right) <a href="Exception.html#TYPEt">t</a>) -><br>       ('left, 'new_right) <a href="Exception.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">bind a_monad a_function</code>
<p>

    Apply <code class="code">a_function</code> to <code class="code">a_monad</code> producing another monad.
    <code class="code">a_function</code> takes a normal value as argument and returns a
    monad.<br>
</div>
<pre><span id="VALreturn"><span class="keyword">val</span> return</span> : <code class="type">'right -> ('left, 'right) <a href="Exception.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">return a_normal_value</code>
<p>

    Answer <code class="code">a_normal_value</code>.<br>
</div>
<pre><span id="VALthrow"><span class="keyword">val</span> throw</span> : <code class="type">'left -> ('left, 'right) <a href="Exception.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">throw an_exception</code>
<p>

    Answer <code class="code">an_exception</code>, or in other words, throw <code class="code">an_exception</code>.<br>
</div>
<pre><span id="VALcatch"><span class="keyword">val</span> catch</span> : <code class="type">('left, 'right) <a href="Exception.html#TYPEt">t</a> -><br>       ('left -> ('new_left, 'right) <a href="Exception.html#TYPEt">t</a>) -> ('new_left, 'right) <a href="Exception.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">catch a_monad an_exception_handler</code>
<p>

    Catch exceptions from <code class="code">a_monad</code> and feed them into
    <code class="code">an_exception_handler</code>.  <code class="code">an_exception_handler</code> takes an
    exceptional value as argument and returns a monad.<br>
</div>
<pre><span id="VALrun"><span class="keyword">val</span> run</span> : <code class="type">('left -> 'a) -> ('right -> 'a) -> ('left, 'right) <a href="Exception.html#TYPEt">t</a> -> 'a</code></pre><div class="info">
<code class="code">run a_failure_function a_success_function a_monad</code>
<p>

    Run <code class="code">a_monad</code>.  If <code class="code">a_monad</code> does not <a href="Exception.html#VALthrow"><code class="code">Exception.throw</code></a> an
    exception, pass the result of evaluating the monad to
    <code class="code">a_success_function</code>.  Otherwise, if the <code class="code">a_monad</code> throws, pass
    the exception to <code class="code">a_failure_function</code>.<br>
</div>
</body></html>