Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / SMLNJLibrary
CommitLineData
7f918cf1
CE
1<!DOCTYPE html>\r
2<html lang="en">\r
3<head>\r
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
5<meta name="generator" content="AsciiDoc 8.6.9">\r
6<title>SMLNJLibrary</title>\r
7<link rel="stylesheet" href="./asciidoc.css" type="text/css">\r
8<link rel="stylesheet" href="./pygments.css" type="text/css">\r
9\r
10\r
11<script type="text/javascript" src="./asciidoc.js"></script>\r
12<script type="text/javascript">\r
13/*<![CDATA[*/\r
14asciidoc.install();\r
15/*]]>*/\r
16</script>\r
17<link rel="stylesheet" href="./mlton.css" type="text/css">\r
18</head>\r
19<body class="article">\r
20<div id="banner">\r
21<div id="banner-home">\r
22<a href="./Home">MLton 20180207</a>\r
23</div>\r
24</div>\r
25<div id="header">\r
26<h1>SMLNJLibrary</h1>\r
27</div>\r
28<div id="content">\r
29<div id="preamble">\r
30<div class="sectionbody">\r
31<div class="paragraph"><p>The <a href="http://www.smlnj.org/doc/smlnj-lib/index.html">SML/NJ Library</a> is a\r
32collection of libraries that are distributed with SML/NJ. Due to\r
33differences between SML/NJ and MLton, these libraries will not work\r
34out-of-the box with MLton.</p></div>\r
35<div class="paragraph"><p>As of 20180119, MLton includes a port of the SML/NJ Library\r
36synchronized with SML/NJ version 110.82.</p></div>\r
37</div>\r
38</div>\r
39<div class="sect1">\r
40<h2 id="_usage">Usage</h2>\r
41<div class="sectionbody">\r
42<div class="ulist"><ul>\r
43<li>\r
44<p>\r
45You can import a sub-library of the SML/NJ Library into an MLB file with:\r
46</p>\r
47<table class="tableblock frame-all grid-all"\r
48style="\r
49width:100%;\r
50">\r
51<col style="width:50%;">\r
52<col style="width:50%;">\r
53<thead>\r
54<tr>\r
55<th class="tableblock halign-left valign-top" >MLB file</th>\r
56<th class="tableblock halign-left valign-top" >Description</th>\r
57</tr>\r
58</thead>\r
59<tbody>\r
60<tr>\r
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>\r
62<td class="tableblock halign-left valign-top" ><p class="tableblock">Various utility modules, included collections, simple formating, &#8230;</p></td>\r
63</tr>\r
64<tr>\r
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>\r
66<td class="tableblock halign-left valign-top" ><p class="tableblock">A library for managing control flags in an application.</p></td>\r
67</tr>\r
68<tr>\r
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>\r
70<td class="tableblock halign-left valign-top" ><p class="tableblock">Support for implementing hash-consed data structures.</p></td>\r
71</tr>\r
72<tr>\r
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>\r
74<td class="tableblock halign-left valign-top" ><p class="tableblock">HTML 3.2 parsing and pretty-printing library.</p></td>\r
75</tr>\r
76<tr>\r
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>\r
78<td class="tableblock halign-left valign-top" ><p class="tableblock">HTML 4.01 parsing and pretty-printing library.</p></td>\r
79</tr>\r
80<tr>\r
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>\r
82<td class="tableblock halign-left valign-top" ><p class="tableblock">Networking utilities; supported on both Unix and Windows systems.</p></td>\r
83</tr>\r
84<tr>\r
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>\r
86<td class="tableblock halign-left valign-top" ><p class="tableblock">JavaScript Object Notation (JSON) reading and writing library.</p></td>\r
87</tr>\r
88<tr>\r
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>\r
90<td class="tableblock halign-left valign-top" ><p class="tableblock">Pretty-printing library.</p></td>\r
91</tr>\r
92<tr>\r
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>\r
94<td class="tableblock halign-left valign-top" ><p class="tableblock">Reactive scripting library.</p></td>\r
95</tr>\r
96<tr>\r
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>\r
98<td class="tableblock halign-left valign-top" ><p class="tableblock">Regular expression library.</p></td>\r
99</tr>\r
100<tr>\r
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>\r
102<td class="tableblock halign-left valign-top" ><p class="tableblock">S-expression library.</p></td>\r
103</tr>\r
104<tr>\r
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>\r
106<td class="tableblock halign-left valign-top" ><p class="tableblock">Utilities for Unix-based operating systems.</p></td>\r
107</tr>\r
108<tr>\r
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>\r
110<td class="tableblock halign-left valign-top" ><p class="tableblock">XML library.</p></td>\r
111</tr>\r
112</tbody>\r
113</table>\r
114</li>\r
115<li>\r
116<p>\r
117If you are porting a project from SML/NJ&#8217;s <a href="CompilationManager">CompilationManager</a> to\r
118MLton&#8217;s <a href="MLBasis"> ML Basis system</a> using <span class="monospaced">cm2mlb</span>, note that the\r
119following maps are included by default:\r
120</p>\r
121<div class="listingblock">\r
122<div class="content monospaced">\r
123<pre># SMLNJ Library\r
124$SMLNJ-LIB $(SML_LIB)/smlnj-lib\r
125$smlnj-lib.cm $(SML_LIB)/smlnj-lib/Util\r
126$controls-lib.cm $(SML_LIB)/smlnj-lib/Controls\r
127$hash-cons-lib.cm $(SML_LIB)/smlnj-lib/HashCons\r
128$html-lib.cm $(SML_LIB)/smlnj-lib/HTML\r
129$html4-lib.cm $(SML_LIB)/smlnj-lib/HTML4\r
130$inet-lib.cm $(SML_LIB)/smlnj-lib/INet\r
131$json-lib.cm $(SML_LIB)/smlnj-lib/JSON\r
132$pp-lib.cm $(SML_LIB)/smlnj-lib/PP\r
133$reactive-lib.cm $(SML_LIB)/smlnj-lib/Reactive\r
134$regexp-lib.cm $(SML_LIB)/smlnj-lib/RegExp\r
135$sexp-lib.cm $(SML_LIB)/smlnj-lib/SExp\r
136$unix-lib.cm $(SML_LIB)/smlnj-lib/Unix\r
137$xml-lib.cm $(SML_LIB)/smlnj-lib/XML</pre>\r
138</div></div>\r
139<div class="paragraph"><p>This will automatically convert a <span class="monospaced">$/smlnj-lib.cm</span> import in an input\r
140<span class="monospaced">.cm</span> file into a <span class="monospaced">$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb</span> import in\r
141the output <span class="monospaced">.mlb</span> file.</p></div>\r
142</li>\r
143</ul></div>\r
144</div>\r
145</div>\r
146<div class="sect1">\r
147<h2 id="_details">Details</h2>\r
148<div class="sectionbody">\r
149<div class="paragraph"><p>The following changes were made to the SML/NJ Library, in addition to\r
150deriving the <span class="monospaced">.mlb</span> files from the <span class="monospaced">.cm</span> files:</p></div>\r
151<div class="ulist"><ul>\r
152<li>\r
153<p>\r
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.\r
155</p>\r
156</li>\r
157<li>\r
158<p>\r
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.\r
160</p>\r
161</li>\r
162<li>\r
163<p>\r
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>.\r
165</p>\r
166</li>\r
167<li>\r
168<p>\r
169<span class="monospaced">Util/graph-scc-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.\r
170</p>\r
171</li>\r
172<li>\r
173<p>\r
174<span class="monospaced">Util/redblack-map-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.\r
175</p>\r
176</li>\r
177<li>\r
178<p>\r
179<span class="monospaced">Util/redblack-set-fn.sml</span> (modified): Rewrote use of <span class="monospaced">where</span> structure specification.\r
180</p>\r
181</li>\r
182<li>\r
183<p>\r
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>.\r
185</p>\r
186</li>\r
187<li>\r
188<p>\r
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.\r
190</p>\r
191</li>\r
192</ul></div>\r
193</div>\r
194</div>\r
195<div class="sect1">\r
196<h2 id="_patch">Patch</h2>\r
197<div class="sectionbody">\r
198<div class="ulist"><ul>\r
199<li>\r
200<p>\r
201<a href="https://github.com/MLton/mlton/blob/master/lib/smlnj-lib/smlnj-lib.patch"><span class="monospaced">smlnj-lib.patch</span></a>\r
202</p>\r
203</li>\r
204</ul></div>\r
205</div>\r
206</div>\r
207</div>\r
208<div id="footnotes"><hr></div>\r
209<div id="footer">\r
210<div id="footer-text">\r
211</div>\r
212<div id="footer-badges">\r
213</div>\r
214</div>\r
215</body>\r
216</html>\r