MLton is a whole-program optimizing compiler for the Standard ML programming language. MLton generates small executables with excellent runtime performance, utilizing untagged and unboxed native integers, reals, and words, unboxed native arrays, fast arbitrary-precision arithmetic based on GMP, and multiple code generation and garbage collection strategies. In addition, MLton provides a feature rich Standard ML programming environment, with full support for SML97 as given in The Definition of Standard ML (Revised), a number of useful language extensions, a complete implementation of the Standard ML Basis Library, various useful libraries, a simple and fast C foreign function interface, the ML Basis system for programming with source libraries, and tools such as a lexer generator, a parser generator, and a profiler.
-
Robustness.
-
Supports the full SML 97 language as given in The Definition of Standard ML (Revised).
-
A complete implementation of the Basis Library.
-
Generates standalone executables.
-
Compiles large programs.
-
Support for large amounts of memory (up to 4G on 32-bit systems; more on 64-bit systems).
-
Support for large array lengths (up to 231 - 1 on 32-bit systems; up to 263-1 on 64-bit systems).
-
Support for large files, using 64-bit file positions.
-
-
Performance.
-
Executables have excellent runtime performance.
-
Generates small executables.
-
Untagged and unboxed native integers, reals, and words.
-
Unboxed native arrays.
-
Multiple garbage collection strategies.
-
Fast arbitrary-precision arithmetic based on GMP.
-
-
Tools.
-
Source-level profiling for both time and allocation.
-
MLLex lexer generator.
-
MLYacc parser generator.
-
MLNLFFIGEN foreign-function-interface generator.
-
-
Extensions.
-
The ML Basis system for programming with source libraries.
-
A number of useful language extensions.
-
A simple and fast C FFI that supports calling from SML to C and from C to SML.
-
Libraries for weak pointers and finalization, threads, continuations, interval timers and signal handlers, world save and restore, and more.
-
-
Portability.
-
Runs on a wide variety of platforms.
-
-
GMP (GNU Multiple Precision arithmetic library)
-
binutils (
ar
,ranlib
,strip
, …) -
miscellaneous Unix utilities (
diff
,find
,grep
,gzip
,patch
,sed
,tar
, …) -
Standard ML compiler to bootstrap:
-
MLton (
mlton
) recommended. Pre-built binary packages for MLton can be installed via an OS package manager or (for select platforms) obtained fromhttp://mlton.org
. -
SML/NJ (
sml
) supported, but not recommended. -
Poly/ML (
polyc
) supported, but not recommended. -
MLKit (
mlkit
) supported, but not recommended.
-
-
(optional, for documentation only) TeX, AsciiDoctor, Rouge, GraphicsMagick or ImageMagick, …
On typical platforms, building MLton requires no configuration and can be accomplished via:
$ make all
A small set of Makefile
variables can be used to customize the build:
-
CC
: Specify C compiler. Can be used for alternative tools (e.g.,CC=clang
orCC=gcc-7
). -
WITH_GMP_DIR
,WITH_GMP_INC_DIR
,WITH_GMP_LIB_DIR
: Specify GMP include and library paths, if not on default search paths. (IfWITH_GMP_DIR
is set, thenWITH_GMP_INC_DIR
defaults to$(WITH_GMP_DIR)/include
andWITH_GMP_LIB_DIR
defaults to$(WITH_GMP_DIR)/lib
.) -
MLTON_RUNTIME_ARGS
,MLTON_COMPILE_ARGS
: Specify runtime and compile arguments given to (the to-be-built)mlton
when compiling distributed executables ((self-compiled)mlton
,mllex
,mlyacc
,mlprof
, andmlnlffigen
). Can be used for testing (e.g.,MLTON_COMPILE_ARGS="-codegen c"
) or for downstream packaging. -
OLD_MLTON_RUNTIME_ARGS
,OLD_MLTON_COMPILE_ARGS
: Specify runtime and compile arguments given to "old"mlton
when compiling "new"mlton
. Can be used to work around bugs in "old"mlton
when compiling "new"mlton
.
For example:
$ make CC=clang WITH_GMP_DIR=/opt/gmp MLTON_COMPILE_ARGS="-codegen c" all
The build artifacts are located under ./build
. The just-built mlton
can be
executed via ./build/bin/mlton
.
Building documentation can be accomplished via:
$ make docs
On typical platforms, installing MLton (after performing make all
and,
optionally, make docs
) to /usr/local
can be accomplished via:
$ make install
A small set of Makefile
variables can be used to customize the installation:
-
PREFIX
: Specify the installation prefix.
For example:
$ make PREFIX=/opt/mlton install
A .tgz
or .tbz
binary package can be extracted at any location, yielding
README.adoc
(this file), CHANGELOG.adoc
, LICENSE
, Makefile
, bin/
,
lib/
, and share/
. The compiler and tools can be executed in-place (e.g.,
./bin/mlton
).
A small set of Makefile
variables can be used to customize the binary package
via make update
:
-
CC
: Specify C compiler. Can be used for alternative tools (e.g.,CC=clang
orCC=gcc-7
). -
WITH_GMP_DIR
,WITH_GMP_INC_DIR
,WITH_GMP_LIB_DIR
: Specify GMP include and library paths, if not on default search paths. (IfWITH_GMP_DIR
is set, thenWITH_GMP_INC_DIR
defaults to$(WITH_GMP_DIR)/include
andWITH_GMP_LIB_DIR
defaults to$(WITH_GMP_DIR)/lib
.)
For example:
$ make CC=clang WITH_GMP_DIR=/opt/gmp update
On typical platforms, installing MLton (after optionally performing
make update
) to /usr/local
can be accomplished via:
$ make install
A small set of Makefile
variables can be used to customize the installation:
-
PREFIX
: Specify the installation prefix.
For example:
$ make PREFIX=/opt/mlton install
-
Development
-
Mailing lists
-
[email protected]
— MLton developers (archive, subscribe) -
[email protected]
— MLton user community (archive, subscribe)
-
To report bugs or suggest new features, use the issue tracker or ask on the mailing list.
Pull requests with bug fixes or changes are welcome.