4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
6 <title>SMLNJLibrary</title>
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
19 <body class="article">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
30 <div class="sectionbody">
31 <div class="paragraph"><p>The <a href="http://www.smlnj.org/doc/smlnj-lib/index.html">SML/NJ Library</a> is a
32 collection of libraries that are distributed with SML/NJ. Due to
33 differences between SML/NJ and MLton, these libraries will not work
34 out-of-the box with MLton.</p></div>
35 <div class="paragraph"><p>As of 20180119, MLton includes a port of the SML/NJ Library
36 synchronized with SML/NJ version 110.82.</p></div>
40 <h2 id="_usage">Usage</h2>
41 <div class="sectionbody">
42 <div class="ulist"><ul>
45 You can import a sub-library of the SML/NJ Library into an MLB file with:
47 <table class="tableblock frame-all grid-all"
51 <col style="width:50%;">
52 <col style="width:50%;">
55 <th class="tableblock halign-left valign-top" >MLB file</th>
56 <th class="tableblock halign-left valign-top" >Description</th>
61 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb</span></p></td>
62 <td class="tableblock halign-left valign-top" ><p class="tableblock">Various utility modules, included collections, simple formating, …</p></td>
65 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/Controls/controls-lib.mlb</span></p></td>
66 <td class="tableblock halign-left valign-top" ><p class="tableblock">A library for managing control flags in an application.</p></td>
69 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/HashCons/hash-cons-lib.mlb</span></p></td>
70 <td class="tableblock halign-left valign-top" ><p class="tableblock">Support for implementing hash-consed data structures.</p></td>
73 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/HTML/html-lib.mlb</span></p></td>
74 <td class="tableblock halign-left valign-top" ><p class="tableblock">HTML 3.2 parsing and pretty-printing library.</p></td>
77 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/HTML4/html4-lib.mlb</span></p></td>
78 <td class="tableblock halign-left valign-top" ><p class="tableblock">HTML 4.01 parsing and pretty-printing library.</p></td>
81 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/INet/inet-lib.mlb</span></p></td>
82 <td class="tableblock halign-left valign-top" ><p class="tableblock">Networking utilities; supported on both Unix and Windows systems.</p></td>
85 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/JSON/json-lib.mlb</span></p></td>
86 <td class="tableblock halign-left valign-top" ><p class="tableblock">JavaScript Object Notation (JSON) reading and writing library.</p></td>
89 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/PP/pp-lib.mlb</span></p></td>
90 <td class="tableblock halign-left valign-top" ><p class="tableblock">Pretty-printing library.</p></td>
93 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/Reactive/reactive-lib.mlb</span></p></td>
94 <td class="tableblock halign-left valign-top" ><p class="tableblock">Reactive scripting library.</p></td>
97 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/RegExp/regexp-lib.mlb</span></p></td>
98 <td class="tableblock halign-left valign-top" ><p class="tableblock">Regular expression library.</p></td>
101 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/SExp/sexp-lib.mlb</span></p></td>
102 <td class="tableblock halign-left valign-top" ><p class="tableblock">S-expression library.</p></td>
105 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/Unix/unix-lib.mlb</span></p></td>
106 <td class="tableblock halign-left valign-top" ><p class="tableblock">Utilities for Unix-based operating systems.</p></td>
109 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/smlnj-lib/XML/xml-lib.mlb</span></p></td>
110 <td class="tableblock halign-left valign-top" ><p class="tableblock">XML library.</p></td>
117 If you are porting a project from SML/NJ’s <a href="CompilationManager">CompilationManager</a> to
118 MLton’s <a href="MLBasis"> ML Basis system</a> using <span class="monospaced">cm2mlb</span>, note that the
119 following maps are included by default:
121 <div class="listingblock">
122 <div class="content monospaced">
124 $SMLNJ-LIB $(SML_LIB)/smlnj-lib
125 $smlnj-lib.cm $(SML_LIB)/smlnj-lib/Util
126 $controls-lib.cm $(SML_LIB)/smlnj-lib/Controls
127 $hash-cons-lib.cm $(SML_LIB)/smlnj-lib/HashCons
128 $html-lib.cm $(SML_LIB)/smlnj-lib/HTML
129 $html4-lib.cm $(SML_LIB)/smlnj-lib/HTML4
130 $inet-lib.cm $(SML_LIB)/smlnj-lib/INet
131 $json-lib.cm $(SML_LIB)/smlnj-lib/JSON
132 $pp-lib.cm $(SML_LIB)/smlnj-lib/PP
133 $reactive-lib.cm $(SML_LIB)/smlnj-lib/Reactive
134 $regexp-lib.cm $(SML_LIB)/smlnj-lib/RegExp
135 $sexp-lib.cm $(SML_LIB)/smlnj-lib/SExp
136 $unix-lib.cm $(SML_LIB)/smlnj-lib/Unix
137 $xml-lib.cm $(SML_LIB)/smlnj-lib/XML</pre>
139 <div class="paragraph"><p>This will automatically convert a <span class="monospaced">$/smlnj-lib.cm</span> import in an input
140 <span class="monospaced">.cm</span> file into a <span class="monospaced">$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb</span> import in
141 the output <span class="monospaced">.mlb</span> file.</p></div>
147 <h2 id="_details">Details</h2>
148 <div class="sectionbody">
149 <div class="paragraph"><p>The following changes were made to the SML/NJ Library, in addition to
150 deriving the <span class="monospaced">.mlb</span> files from the <span class="monospaced">.cm</span> files:</p></div>
151 <div class="ulist"><ul>
154 <span class="monospaced">HTML4/pp-init.sml</span> (added): Implements <span class="monospaced">structure PrettyPrint</span> using the SML/NJ PP Library. This implementation is taken from the SML/NJ compiler source, since the SML/NJ HTML4 Library used the <span class="monospaced">structure PrettyPrint</span> provided by the SML/NJ compiler itself.
159 <span class="monospaced">Util/base64.sml</span> (modified): Rewrote use of <span class="monospaced">Unsafe.CharVector.create</span> and <span class="monospaced">Unsafe.CharVector.update</span>; MLton assumes that vectors are immutable.
164 <span class="monospaced">Util/engine.mlton.sml</span> (added, not exported): Implements <span class="monospaced">structure Engine</span>, providing time-limited, resumable computations using <a href="MLtonThread">MLtonThread</a>, <a href="MLtonSignal">MLtonSignal</a>, and <a href="MLtonItimer">MLtonItimer</a>.
169 <span class="monospaced">Util/graph-scc-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
174 <span class="monospaced">Util/redblack-map-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
179 <span class="monospaced">Util/redblack-set-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
184 <span class="monospaced">Util/time-limit.mlb</span> (added): Exports <span class="monospaced">structure TimeLimit</span>, which is <em>not</em> exported by <span class="monospaced">smlnj-lib.mlb</span>. Since MLton is very conservative in the presence of threads and signals, program performance may be adversely affected by unnecessarily including <span class="monospaced">structure TimeLimit</span>.
189 <span class="monospaced">Util/time-limit.mlton.sml</span> (added): Implements <span class="monospaced">structure TimeLimit</span> using <span class="monospaced">structure Engine</span>. The SML/NJ implementation of <span class="monospaced">structure TimeLimit</span> uses SML/NJ’s first-class continuations, signals, and interval timer.
196 <h2 id="_patch">Patch</h2>
197 <div class="sectionbody">
198 <div class="ulist"><ul>
201 <a href="https://github.com/MLton/mlton/blob/master/lib/smlnj-lib/smlnj-lib.patch"><span class="monospaced">smlnj-lib.patch</span></a>
208 <div id="footnotes"><hr></div>
210 <div id="footer-text">
212 <div id="footer-badges">