Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / doc / guide / localhost / SMLNJLibrary
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
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">
9
10
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
13 /*<![CDATA[*/
14 asciidoc.install();
15 /*]]>*/
16 </script>
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
18 </head>
19 <body class="article">
20 <div id="banner">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
23 </div>
24 </div>
25 <div id="header">
26 <h1>SMLNJLibrary</h1>
27 </div>
28 <div id="content">
29 <div id="preamble">
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>
37 </div>
38 </div>
39 <div class="sect1">
40 <h2 id="_usage">Usage</h2>
41 <div class="sectionbody">
42 <div class="ulist"><ul>
43 <li>
44 <p>
45 You can import a sub-library of the SML/NJ Library into an MLB file with:
46 </p>
47 <table class="tableblock frame-all grid-all"
48 style="
49 width:100%;
50 ">
51 <col style="width:50%;">
52 <col style="width:50%;">
53 <thead>
54 <tr>
55 <th class="tableblock halign-left valign-top" >MLB file</th>
56 <th class="tableblock halign-left valign-top" >Description</th>
57 </tr>
58 </thead>
59 <tbody>
60 <tr>
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, &#8230;</p></td>
63 </tr>
64 <tr>
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>
67 </tr>
68 <tr>
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>
71 </tr>
72 <tr>
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>
75 </tr>
76 <tr>
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>
79 </tr>
80 <tr>
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>
83 </tr>
84 <tr>
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>
87 </tr>
88 <tr>
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>
91 </tr>
92 <tr>
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>
95 </tr>
96 <tr>
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>
99 </tr>
100 <tr>
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>
103 </tr>
104 <tr>
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>
107 </tr>
108 <tr>
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>
111 </tr>
112 </tbody>
113 </table>
114 </li>
115 <li>
116 <p>
117 If you are porting a project from SML/NJ&#8217;s <a href="CompilationManager">CompilationManager</a> to
118 MLton&#8217;s <a href="MLBasis"> ML Basis system</a> using <span class="monospaced">cm2mlb</span>, note that the
119 following maps are included by default:
120 </p>
121 <div class="listingblock">
122 <div class="content monospaced">
123 <pre># SMLNJ Library
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>
138 </div></div>
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>
142 </li>
143 </ul></div>
144 </div>
145 </div>
146 <div class="sect1">
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>
152 <li>
153 <p>
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.
155 </p>
156 </li>
157 <li>
158 <p>
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.
160 </p>
161 </li>
162 <li>
163 <p>
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>.
165 </p>
166 </li>
167 <li>
168 <p>
169 <span class="monospaced">Util/graph-scc-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
170 </p>
171 </li>
172 <li>
173 <p>
174 <span class="monospaced">Util/redblack-map-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
175 </p>
176 </li>
177 <li>
178 <p>
179 <span class="monospaced">Util/redblack-set-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.
180 </p>
181 </li>
182 <li>
183 <p>
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>.
185 </p>
186 </li>
187 <li>
188 <p>
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&#8217;s first-class continuations, signals, and interval timer.
190 </p>
191 </li>
192 </ul></div>
193 </div>
194 </div>
195 <div class="sect1">
196 <h2 id="_patch">Patch</h2>
197 <div class="sectionbody">
198 <div class="ulist"><ul>
199 <li>
200 <p>
201 <a href="https://github.com/MLton/mlton/blob/master/lib/smlnj-lib/smlnj-lib.patch"><span class="monospaced">smlnj-lib.patch</span></a>
202 </p>
203 </li>
204 </ul></div>
205 </div>
206 </div>
207 </div>
208 <div id="footnotes"><hr></div>
209 <div id="footer">
210 <div id="footer-text">
211 </div>
212 <div id="footer-badges">
213 </div>
214 </div>
215 </body>
216 </html>