<!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="Exception.html"> <link rel="next" href="Utest.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"><link title="IO-Monad" rel="Section" href="#3_IOMonad"> <link title="Types" rel="Subsection" href="#4_Types"> <title>Io</title> </head> <body> <div class="navbar"><a href="Exception.html">Previous</a> <a href="pa_monad.html">Up</a> <a href="Utest.html">Next</a> </div> <center><h1>Module <a href="type_Io.html">Io</a></h1></center> <br> <pre><span class="keyword">module</span> Io: <code class="code">sig</code> <a href="Io.html">..</a> <code class="code">end</code></pre>Rudimentary I/O-monad<br> <hr width="100%"> <br> <a name="3_IOMonad"></a> <h3>IO-Monad</h3><br> <br> <a name="4_Types"></a> <h4>Types</h4><br> <br><code><span class="keyword">type</span> <a name="TYPEerror"></a><code class="type"></code>error = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">EndOfFile</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Tried to read beyond end of file</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">IntOfString</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Could not convert <code class="code">string</code> to <code class="code">int</code></td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">SysError</span> <span class="keyword">of</span> <code class="type">string</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Operating system signaled an error. The <code class="code">string</code> takes the precise reason.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info"> Possible errors during an IO-operation. They are named after their imperative counterparts.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEworld"></a><code class="type"></code>world </pre> <div class="info"> The imperative, "outside" world the <em>functional</em> IO-monad deals with.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEeither"></a><code class="type">('a, 'b)</code> either </pre> <pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type">'a</code> t = <code class="type"><a href="Io.html#TYPEworld">world</a> -> (<a href="Io.html#TYPEerror">error</a>, 'a) <a href="Io.html#TYPEeither">either</a> * <a href="Io.html#TYPEworld">world</a></code> </pre> <div class="info"> An IO-monad of type <code class="code">'a</code> takes the current world and produces either a correct value (of type <code class="code">'a</code> or an <code class="code">error</code> and a new world.<br> </div> <pre><span class="keyword">val</span> <a name="VAL__conjure_up"></a>__conjure_up : <code class="type">unit -> <a href="Io.html#TYPEworld">world</a></code></pre><pre><span class="keyword">val</span> <a name="VALbind"></a>bind : <code class="type">'a <a href="Io.html#TYPEt">t</a> -> ('a -> 'b <a href="Io.html#TYPEt">t</a>) -> 'b <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALreturn"></a>return : <code class="type">'a -> 'a <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALthrow"></a>throw : <code class="type"><a href="Io.html#TYPEerror">error</a> -> 'a <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALcatch"></a>catch : <code class="type">'a <a href="Io.html#TYPEt">t</a> -> (<a href="Io.html#TYPEerror">error</a> -> 'a <a href="Io.html#TYPEt">t</a>) -> 'a <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_char"></a>print_char : <code class="type">char -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_string"></a>print_string : <code class="type">string -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_int"></a>print_int : <code class="type">int -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_float"></a>print_float : <code class="type">float -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_endline"></a>print_endline : <code class="type">string -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprint_newline"></a>print_newline : <code class="type">unit -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_char"></a>prerr_char : <code class="type">char -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_string"></a>prerr_string : <code class="type">string -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_int"></a>prerr_int : <code class="type">int -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_float"></a>prerr_float : <code class="type">float -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_endline"></a>prerr_endline : <code class="type">string -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprerr_newline"></a>prerr_newline : <code class="type">unit -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALread_line"></a>read_line : <code class="type">unit -> string <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALread_int"></a>read_int : <code class="type">unit -> int <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALread_float"></a>read_float : <code class="type">unit -> float <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALopen_out"></a>open_out : <code class="type">string -> Pervasives.out_channel <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALoutput_char"></a>output_char : <code class="type">Pervasives.out_channel -> char -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALoutput_string"></a>output_string : <code class="type">Pervasives.out_channel -> string -> unit <a href="Io.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALclose_out"></a>close_out : <code class="type">Pervasives.out_channel -> unit <a href="Io.html#TYPEt">t</a></code></pre></body></html>