MLton MLTONWIKIVERSION

SMLNJLibrary

Home Index

The SML/NJ Library is a collection of libraries that are distributed with SML/NJ. Due to differences between SML/NJ and MLton, these libraries will not work out-of-the box with MLton.

As of 20070812, MLton includes a port of the SML/NJ Library, currently synchronized with SML/NJ version 110.65.

## Usage

- You can import a sub-library of the SML/NJ Library into an MLB file with:

  MLB file | Description
  `$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb` | Various utility modules, included collections, simple formating, ...
  `$(SML_LIB)/smlnj-lib/Controls/controls-lib.mlb` | A library for managing control flags in an application.
  `$(SML_LIB)/smlnj-lib/HashCons/hash-cons-lib.mlb` | Support for implementing hash-consed data structures.
  `$(SML_LIB)/smlnj-lib/INet/inet-lib.mlb` | Networking utilities; supported on both Unix and Windows systems.
  `$(SML_LIB)/smlnj-lib/Unix/unix-lib.mlb` | Utilities for Unix-based operating systems.
  `$(SML_LIB)/smlnj-lib/PP/pp-lib.mlb` | Pretty-printing library.
  `$(SML_LIB)/smlnj-lib/HTML/html-lib.mlb` | HTML parsing and pretty-printing library.
  `$(SML_LIB)/smlnj-lib/RegExp/regexp-lib.mlb` | Regular expression library.
  `$(SML_LIB)/smlnj-lib/Reactive/reactive-lib.mlb` | Reactive scripting library.

- If you are porting a project from SML/NJ's CompilationManager to MLton's ML Basis system using `cm2mlb`, note that the following maps are included by default:

      $smlnj-lib.cm       $(SML_LIB)/smlnj-lib/Util
      $controls-lib.cm    $(SML_LIB)/smlnj-lib/Controls
      $hash-cons-lib.cm   $(SML_LIB)/smlnj-lib/HashCons
      $inet-lib.cm        $(SML_LIB)/smlnj-lib/INet
      $unix-lib.cm        $(SML_LIB)/smlnj-lib/Unix
      $pp-lib.cm          $(SML_LIB)/smlnj-lib/PP
      $html-lib.cm        $(SML_LIB)/smlnj-lib/HTML
      $regexp-lib.cm      $(SML_LIB)/smlnj-lib/RegExp
      $reactive-lib.cm    $(SML_LIB)/smlnj-lib/Reactive

  This will automatically convert a `$/smlnj-lib.cm` import in an input `.cm` file into a `$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb` import in the output `.mlb` file.

## Details

The following changes were made to the SML/NJ Library, in addition to deriving the `.mlb` files from the `.cm` files:

- `Util/redblack-set-fn.sml` (modified): Rewrote use of `where` structure specification.

- `Util/redblack-map-fn.sml` (modified): Rewrote use of `where` structure specification.

- `Util/graph-scc.sml` (modified): Rewrote use of `where` structure specification.

- `Util/bit-array.sml` (modified): The computation of the `maxLen` is given by:

      val maxLen = 8*Word8Array.maxLen

  This is fine in SML/NJ where `Word8Array.maxLen` is 16777215, but in MLton, `Word8Array.maxLen` is equal to `valOf(Int.maxInt)`, so the computation overflows. To accommodate both SML/NJ and MLton, the computation is replaced by

      val maxLen = (8*Word8Array.maxLen) handle Overflow => Word8Array.maxLen

- `Util/engine.mlton.sml` (added, not exported): Implements `structure Engine`, providing time-limited, resumable computations using MLtonThread, MLtonSignal, and MLtonItimer.

- `Util/time-limit.mlton.sml` (added): Implements `structure TimeLimit` using `structure Engine`. The SML/NJ implementation of `structure TimeLimit` uses SML/NJ's first-class continuations, signals, and interval timer.

- `Util/time-limit.mlb` (added): Exports `structure TimeLimit`, which is not exported by `smlnj-lib.mlb`. Since MLton is very conservative in the presence of threads and signals, program performance may be adversely affected by unnecessarily including `structure TimeLimit`.

- `HTML/html-elements-fn.sml` (modified): Rewrote use of or-patterns.

- `HTML/html-attrs-fn.sml` (modified): Rewrote use of or-patterns.

## Patch

- smlnj-lib.patch

Last edited on 2007-08-23 17:24:54 by MatthewFluet.