<!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"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="Start" href="index.html"> <link rel="previous" href="Marshal.html"> <link rel="next" href="MoreLabels.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Arg" rel="Chapter" href="Arg.html"> <link title="Arg_helper" rel="Chapter" href="Arg_helper.html"> <link title="Array" rel="Chapter" href="Array.html"> <link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html"> <link title="Ast_helper" rel="Chapter" href="Ast_helper.html"> <link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html"> <link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html"> <link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html"> <link title="Asttypes" rel="Chapter" href="Asttypes.html"> <link title="Attr_helper" rel="Chapter" href="Attr_helper.html"> <link title="Bigarray" rel="Chapter" href="Bigarray.html"> <link title="Buffer" rel="Chapter" href="Buffer.html"> <link title="Build_path_prefix_map" rel="Chapter" href="Build_path_prefix_map.html"> <link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html"> <link title="Bytes" rel="Chapter" href="Bytes.html"> <link title="BytesLabels" rel="Chapter" href="BytesLabels.html"> <link title="Callback" rel="Chapter" href="Callback.html"> <link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html"> <link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html"> <link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html"> <link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html"> <link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html"> <link title="Ccomp" rel="Chapter" href="Ccomp.html"> <link title="Char" rel="Chapter" href="Char.html"> <link title="Clflags" rel="Chapter" href="Clflags.html"> <link title="Complex" rel="Chapter" href="Complex.html"> <link title="Condition" rel="Chapter" href="Condition.html"> <link title="Config" rel="Chapter" href="Config.html"> <link title="Consistbl" rel="Chapter" href="Consistbl.html"> <link title="Depend" rel="Chapter" href="Depend.html"> <link title="Digest" rel="Chapter" href="Digest.html"> <link title="Docstrings" rel="Chapter" href="Docstrings.html"> <link title="Dynlink" rel="Chapter" href="Dynlink.html"> <link title="Ephemeron" rel="Chapter" href="Ephemeron.html"> <link title="Event" rel="Chapter" href="Event.html"> <link title="Filename" rel="Chapter" href="Filename.html"> <link title="Float" rel="Chapter" href="Float.html"> <link title="Format" rel="Chapter" href="Format.html"> <link title="Gc" rel="Chapter" href="Gc.html"> <link title="Genlex" rel="Chapter" href="Genlex.html"> <link title="Graphics" rel="Chapter" href="Graphics.html"> <link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html"> <link title="Hashtbl" rel="Chapter" href="Hashtbl.html"> <link title="Identifiable" rel="Chapter" href="Identifiable.html"> <link title="Int32" rel="Chapter" href="Int32.html"> <link title="Int64" rel="Chapter" href="Int64.html"> <link title="Lazy" rel="Chapter" href="Lazy.html"> <link title="Lexer" rel="Chapter" href="Lexer.html"> <link title="Lexing" rel="Chapter" href="Lexing.html"> <link title="List" rel="Chapter" href="List.html"> <link title="ListLabels" rel="Chapter" href="ListLabels.html"> <link title="Location" rel="Chapter" href="Location.html"> <link title="Longident" rel="Chapter" href="Longident.html"> <link title="Map" rel="Chapter" href="Map.html"> <link title="Marshal" rel="Chapter" href="Marshal.html"> <link title="Misc" rel="Chapter" href="Misc.html"> <link title="MoreLabels" rel="Chapter" href="MoreLabels.html"> <link title="Mutex" rel="Chapter" href="Mutex.html"> <link title="Nativeint" rel="Chapter" href="Nativeint.html"> <link title="Numbers" rel="Chapter" href="Numbers.html"> <link title="Obj" rel="Chapter" href="Obj.html"> <link title="Oo" rel="Chapter" href="Oo.html"> <link title="Parse" rel="Chapter" href="Parse.html"> <link title="Parser" rel="Chapter" href="Parser.html"> <link title="Parsetree" rel="Chapter" href="Parsetree.html"> <link title="Parsing" rel="Chapter" href="Parsing.html"> <link title="Pervasives" rel="Chapter" href="Pervasives.html"> <link title="Pparse" rel="Chapter" href="Pparse.html"> <link title="Pprintast" rel="Chapter" href="Pprintast.html"> <link title="Printast" rel="Chapter" href="Printast.html"> <link title="Printexc" rel="Chapter" href="Printexc.html"> <link title="Printf" rel="Chapter" href="Printf.html"> <link title="Profile" rel="Chapter" href="Profile.html"> <link title="Queue" rel="Chapter" href="Queue.html"> <link title="Random" rel="Chapter" href="Random.html"> <link title="Scanf" rel="Chapter" href="Scanf.html"> <link title="Seq" rel="Chapter" href="Seq.html"> <link title="Set" rel="Chapter" href="Set.html"> <link title="Simplif" rel="Chapter" href="Simplif.html"> <link title="Sort" rel="Chapter" href="Sort.html"> <link title="Spacetime" rel="Chapter" href="Spacetime.html"> <link title="Stack" rel="Chapter" href="Stack.html"> <link title="StdLabels" rel="Chapter" href="StdLabels.html"> <link title="Str" rel="Chapter" href="Str.html"> <link title="Stream" rel="Chapter" href="Stream.html"> <link title="String" rel="Chapter" href="String.html"> <link title="StringLabels" rel="Chapter" href="StringLabels.html"> <link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html"> <link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html"> <link title="Sys" rel="Chapter" href="Sys.html"> <link title="Targetint" rel="Chapter" href="Targetint.html"> <link title="Tbl" rel="Chapter" href="Tbl.html"> <link title="Terminfo" rel="Chapter" href="Terminfo.html"> <link title="Thread" rel="Chapter" href="Thread.html"> <link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html"> <link title="Typemod" rel="Chapter" href="Typemod.html"> <link title="Uchar" rel="Chapter" href="Uchar.html"> <link title="Unix" rel="Chapter" href="Unix.html"> <link title="UnixLabels" rel="Chapter" href="UnixLabels.html"> <link title="Warnings" rel="Chapter" href="Warnings.html"> <link title="Weak" rel="Chapter" href="Weak.html"><link title="Hook machinery" rel="Section" href="#1_Hookmachinery"> <title>Misc</title> </head> <body> <div class="navbar"><a class="pre" href="Marshal.html" title="Marshal">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="MoreLabels.html" title="MoreLabels">Next</a> </div> <h1>Module <a href="type_Misc.html">Misc</a></h1> <pre><span id="MODULEMisc"><span class="keyword">module</span> Misc</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Misc.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><hr width="100%"> <pre><span id="VALfatal_error"><span class="keyword">val</span> fatal_error</span> : <code class="type">string -> 'a</code></pre> <pre><span id="VALfatal_errorf"><span class="keyword">val</span> fatal_errorf</span> : <code class="type">('a, <a href="Format.html#TYPEformatter">Format.formatter</a>, unit, 'b) <a href="Pervasives.html#TYPEformat4">format4</a> -> 'a</code></pre> <pre><span id="EXCEPTIONFatal_error"><span class="keyword">exception</span> Fatal_error</span></pre> <pre><span id="VALtry_finally"><span class="keyword">val</span> try_finally</span> : <code class="type">(unit -> 'a) -> (unit -> unit) -> 'a</code></pre> <pre><span id="VALmap_end"><span class="keyword">val</span> map_end</span> : <code class="type">('a -> 'b) -> 'a list -> 'b list -> 'b list</code></pre> <pre><span id="VALmap_left_right"><span class="keyword">val</span> map_left_right</span> : <code class="type">('a -> 'b) -> 'a list -> 'b list</code></pre> <pre><span id="VALfor_all2"><span class="keyword">val</span> for_all2</span> : <code class="type">('a -> 'b -> bool) -> 'a list -> 'b list -> bool</code></pre> <pre><span id="VALreplicate_list"><span class="keyword">val</span> replicate_list</span> : <code class="type">'a -> int -> 'a list</code></pre> <pre><span id="VALlist_remove"><span class="keyword">val</span> list_remove</span> : <code class="type">'a -> 'a list -> 'a list</code></pre> <pre><span id="VALsplit_last"><span class="keyword">val</span> split_last</span> : <code class="type">'a list -> 'a list * 'a</code></pre> <pre><span id="VALmay"><span class="keyword">val</span> may</span> : <code class="type">('a -> unit) -> 'a option -> unit</code></pre> <pre><span id="VALmay_map"><span class="keyword">val</span> may_map</span> : <code class="type">('a -> 'b) -> 'a option -> 'b option</code></pre> <pre><code><span id="TYPEref_and_value"><span class="keyword">type</span> <code class="type"></code>ref_and_value</span> = </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTref_and_value.R"><span class="constructor">R</span></span> <span class="keyword">:</span> <code class="type">'a <a href="Pervasives.html#TYPEref">ref</a> * 'a</code> <span class="keyword">-></span> <code class="type"><a href="Misc.html#TYPEref_and_value">ref_and_value</a></code></code></td> </tr></table> <pre><span id="VALprotect_refs"><span class="keyword">val</span> protect_refs</span> : <code class="type"><a href="Misc.html#TYPEref_and_value">ref_and_value</a> list -> (unit -> 'a) -> 'a</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">protect_refs l f</code> temporarily sets <code class="code">r</code> to <code class="code">v</code> for each <code class="code"><span class="constructor">R</span> (r, v)</code> in <code class="code">l</code> while executing <code class="code">f</code>. The previous contents of the references is restored even if <code class="code">f</code> raises an exception.</p> </div> </div> <pre><span id="MODULEStdlib"><span class="keyword">module</span> <a href="Misc.Stdlib.html">Stdlib</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Misc.Stdlib.html">..</a> <code class="code"><span class="keyword">end</span></code></pre> <pre><span id="VALfind_in_path"><span class="keyword">val</span> find_in_path</span> : <code class="type">string list -> string -> string</code></pre> <pre><span id="VALfind_in_path_rel"><span class="keyword">val</span> find_in_path_rel</span> : <code class="type">string list -> string -> string</code></pre> <pre><span id="VALfind_in_path_uncap"><span class="keyword">val</span> find_in_path_uncap</span> : <code class="type">string list -> string -> string</code></pre> <pre><span id="VALremove_file"><span class="keyword">val</span> remove_file</span> : <code class="type">string -> unit</code></pre> <pre><span id="VALexpand_directory"><span class="keyword">val</span> expand_directory</span> : <code class="type">string -> string -> string</code></pre> <pre><span id="VALcreate_hashtable"><span class="keyword">val</span> create_hashtable</span> : <code class="type">int -> ('a * 'b) list -> ('a, 'b) <a href="Hashtbl.html#TYPEt">Hashtbl.t</a></code></pre> <pre><span id="VALcopy_file"><span class="keyword">val</span> copy_file</span> : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> <a href="Pervasives.html#TYPEout_channel">out_channel</a> -> unit</code></pre> <pre><span id="VALcopy_file_chunk"><span class="keyword">val</span> copy_file_chunk</span> : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> <a href="Pervasives.html#TYPEout_channel">out_channel</a> -> int -> unit</code></pre> <pre><span id="VALstring_of_file"><span class="keyword">val</span> string_of_file</span> : <code class="type"><a href="Pervasives.html#TYPEin_channel">in_channel</a> -> string</code></pre> <pre><span id="VALoutput_to_file_via_temporary"><span class="keyword">val</span> output_to_file_via_temporary</span> : <code class="type">?mode:<a href="Pervasives.html#TYPEopen_flag">open_flag</a> list -><br> string -> (string -> <a href="Pervasives.html#TYPEout_channel">out_channel</a> -> 'a) -> 'a</code></pre> <pre><span id="VALlog2"><span class="keyword">val</span> log2</span> : <code class="type">int -> int</code></pre> <pre><span id="VALalign"><span class="keyword">val</span> align</span> : <code class="type">int -> int -> int</code></pre> <pre><span id="VALno_overflow_add"><span class="keyword">val</span> no_overflow_add</span> : <code class="type">int -> int -> bool</code></pre> <pre><span id="VALno_overflow_sub"><span class="keyword">val</span> no_overflow_sub</span> : <code class="type">int -> int -> bool</code></pre> <pre><span id="VALno_overflow_mul"><span class="keyword">val</span> no_overflow_mul</span> : <code class="type">int -> int -> bool</code></pre> <pre><span id="VALno_overflow_lsl"><span class="keyword">val</span> no_overflow_lsl</span> : <code class="type">int -> int -> bool</code></pre> <pre><span id="MODULEInt_literal_converter"><span class="keyword">module</span> <a href="Misc.Int_literal_converter.html">Int_literal_converter</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Misc.Int_literal_converter.html">..</a> <code class="code"><span class="keyword">end</span></code></pre> <pre><span id="VALchop_extensions"><span class="keyword">val</span> chop_extensions</span> : <code class="type">string -> string</code></pre> <pre><span id="VALsearch_substring"><span class="keyword">val</span> search_substring</span> : <code class="type">string -> string -> int -> int</code></pre> <pre><span id="VALreplace_substring"><span class="keyword">val</span> replace_substring</span> : <code class="type">before:string -> after:string -> string -> string</code></pre> <pre><span id="VALrev_split_words"><span class="keyword">val</span> rev_split_words</span> : <code class="type">string -> string list</code></pre> <pre><span id="VALget_ref"><span class="keyword">val</span> get_ref</span> : <code class="type">'a list <a href="Pervasives.html#TYPEref">ref</a> -> 'a list</code></pre> <pre><span id="VALfst3"><span class="keyword">val</span> fst3</span> : <code class="type">'a * 'b * 'c -> 'a</code></pre> <pre><span id="VALsnd3"><span class="keyword">val</span> snd3</span> : <code class="type">'a * 'b * 'c -> 'b</code></pre> <pre><span id="VALthd3"><span class="keyword">val</span> thd3</span> : <code class="type">'a * 'b * 'c -> 'c</code></pre> <pre><span id="VALfst4"><span class="keyword">val</span> fst4</span> : <code class="type">'a * 'b * 'c * 'd -> 'a</code></pre> <pre><span id="VALsnd4"><span class="keyword">val</span> snd4</span> : <code class="type">'a * 'b * 'c * 'd -> 'b</code></pre> <pre><span id="VALthd4"><span class="keyword">val</span> thd4</span> : <code class="type">'a * 'b * 'c * 'd -> 'c</code></pre> <pre><span id="VALfor4"><span class="keyword">val</span> for4</span> : <code class="type">'a * 'b * 'c * 'd -> 'd</code></pre> <pre><span id="MODULELongString"><span class="keyword">module</span> <a href="Misc.LongString.html">LongString</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Misc.LongString.html">..</a> <code class="code"><span class="keyword">end</span></code></pre> <pre><span id="VALedit_distance"><span class="keyword">val</span> edit_distance</span> : <code class="type">string -> string -> int -> int option</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">edit_distance a b cutoff</code> computes the edit distance between strings <code class="code">a</code> and <code class="code">b</code>. To help efficiency, it uses a cutoff: if the distance <code class="code">d</code> is smaller than <code class="code">cutoff</code>, it returns <code class="code"><span class="constructor">Some</span> d</code>, else <code class="code"><span class="constructor">None</span></code>.</p> <p>The distance algorithm currently used is Damerau-Levenshtein: it computes the number of insertion, deletion, substitution of letters, or swapping of adjacent letters to go from one word to the other. The particular algorithm may change in the future.</p> </div> </div> <pre><span id="VALspellcheck"><span class="keyword">val</span> spellcheck</span> : <code class="type">string list -> string -> string list</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">spellcheck env name</code> takes a list of names <code class="code">env</code> that exist in the current environment and an erroneous <code class="code">name</code>, and returns a list of suggestions taken from <code class="code">env</code>, that are close enough to <code class="code">name</code> that it may be a typo for one of them.</p> </div> </div> <pre><span id="VALdid_you_mean"><span class="keyword">val</span> did_you_mean</span> : <code class="type"><a href="Format.html#TYPEformatter">Format.formatter</a> -> (unit -> string list) -> unit</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">did_you_mean ppf get_choices</code> hints that the user may have meant one of the option returned by calling <code class="code">get_choices</code>. It does nothing if the returned list is empty.</p> <p>The <code class="code">unit <span class="keywordsign">-></span> ...</code> thunking is meant to delay any potentially-slow computation (typically computing edit-distance with many things from the current environment) to when the hint message is to be printed. You should print an understandable error message before calling <code class="code">did_you_mean</code>, so that users get a clear notification of the failure even if producing the hint is slow.</p> </div> </div> <pre><span id="VALcut_at"><span class="keyword">val</span> cut_at</span> : <code class="type">string -> char -> string * string</code></pre><div class="info "> <div class="info-desc"> <p><code class="code"><span class="constructor">String</span>.cut_at s c</code> returns a pair containing the sub-string before the first occurrence of <code class="code">c</code> in <code class="code">s</code>, and the sub-string after the first occurrence of <code class="code">c</code> in <code class="code">s</code>. <code class="code"><span class="keyword">let</span> (before, after) = <span class="constructor">String</span>.cut_at s c <span class="keyword">in</span><br> before ^ <span class="constructor">String</span>.make 1 c ^ after</code> is the identity if <code class="code">s</code> contains <code class="code">c</code>.</p> <p>Raise <code class="code"><span class="constructor">Not_found</span></code> if the character does not appear in the string</p> </div> <ul class="info-attributes"> <li><b>Since</b> 4.01</li> </ul> </div> <pre><span id="MODULEStringSet"><span class="keyword">module</span> <a href="Misc.StringSet.html">StringSet</a></span>: <code class="type"><a href="Set.S.html">Set.S</a></code><code class="type"> with type elt = string</code></pre> <pre><span id="MODULEStringMap"><span class="keyword">module</span> <a href="Misc.StringMap.html">StringMap</a></span>: <code class="type"><a href="Map.S.html">Map.S</a></code><code class="type"> with type key = string</code></pre> <pre><span id="MODULEColor"><span class="keyword">module</span> <a href="Misc.Color.html">Color</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Misc.Color.html">..</a> <code class="code"><span class="keyword">end</span></code></pre> <pre><span id="VALnormalise_eol"><span class="keyword">val</span> normalise_eol</span> : <code class="type">string -> string</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">normalise_eol s</code> returns a fresh copy of <code class="code">s</code> with any '\r' characters removed. Intended for pre-processing text which will subsequently be printed on a channel which performs EOL transformations (i.e. Windows)</p> </div> </div> <pre><span id="VALdelete_eol_spaces"><span class="keyword">val</span> delete_eol_spaces</span> : <code class="type">string -> string</code></pre><div class="info "> <div class="info-desc"> <p><code class="code">delete_eol_spaces s</code> returns a fresh copy of <code class="code">s</code> with any end of line spaces removed. Intended to normalize the output of the toplevel for tests.</p> </div> </div> <h2 id="1_Hookmachinery">Hook machinery</h2> <p>Hooks machinery: <code class="code">add_hook name f</code> will register a function that will be called on the argument of a later call to <code class="code">apply_hooks</code>. Hooks are applied in the lexicographical order of their names.</p> <pre><code><span id="TYPEhook_info"><span class="keyword">type</span> <code class="type"></code>hook_info</span> = {</code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELThook_info.sourcefile">sourcefile</span> : <code class="type">string</code>;</code></td> </tr></table> } <pre><span id="EXCEPTIONHookExnWrapper"><span class="keyword">exception</span> HookExnWrapper</span> <span class="keyword">of</span> <code>{</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTMisc.HookExnWrapper.error">error</span> : <code class="type">exn</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTMisc.HookExnWrapper.hook_name">hook_name</span> : <code class="type">string</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code><span id="TYPEELTMisc.HookExnWrapper.hook_info">hook_info</span> : <code class="type"><a href="Misc.html#TYPEhook_info">hook_info</a></code>;</code></td> </tr></table> } </pre> <div class="info "> <div class="info-desc"> <p>An exception raised by a hook will be wrapped into a <code class="code"><span class="constructor">HookExnWrapper</span></code> constructor by the hook machinery.</p> </div> </div> <pre><span id="VALraise_direct_hook_exn"><span class="keyword">val</span> raise_direct_hook_exn</span> : <code class="type">exn -> 'a</code></pre><div class="info "> <div class="info-desc"> <p>A hook can use <code class="code">raise_unwrapped_hook_exn</code> to raise an exception that will not be wrapped into a <a href="Misc.html#EXCEPTIONHookExnWrapper"><code class="code"><span class="constructor">Misc</span>.<span class="constructor">HookExnWrapper</span></code></a>.</p> </div> </div> <pre><span id="MODULETYPEHookSig"><span class="keyword">module type</span> <a href="Misc.HookSig.html">HookSig</a></span> = <code class="code"><span class="keyword">sig</span></code> <a href="Misc.HookSig.html">..</a> <code class="code"><span class="keyword">end</span></code></pre> <pre><span id="MODULEMakeHooks"><span class="keyword">module</span> <a href="Misc.MakeHooks.html">MakeHooks</a></span>: <div class="sig_block"><code class="code"><span class="keyword">functor</span> (</code><code class="code"><span class="constructor">M</span></code><code class="code"> : </code><code class="code"><span class="keyword">sig</span></code></pre><div class="sig_block"> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre> </div><pre><code class="code"><span class="keyword">end</span></code><code class="code">) <span class="keywordsign">-></span> </code><code class="type"><a href="Misc.HookSig.html">HookSig</a></code><code class="type"> with type t = M.t</code></div></pre></body></html>