No description
Find a file
Victor Freire 4fa947fe41
Some checks failed
check-format / Check format with smlfmt (push) Has been cancelled
Build / Test / Release / Prepare a release (push) Has been cancelled
Build / Test / Release / Build and test (push) Has been cancelled
Build / Test / Release / Build bindist (push) Has been cancelled
Build / Test / Release / Build bindist-1 (push) Has been cancelled
Build / Test / Release / Build bindist-2 (push) Has been cancelled
Build / Test / Release / Build bindist-3 (push) Has been cancelled
Build / Test / Release / Build docs (push) Has been cancelled
checkpoint
2025-12-18 12:25:06 -03:00
.claude checkpoint 2 2025-12-17 18:07:46 -03:00
.github Version 0.3.0 2025-10-12 21:09:07 +09:00
bin Add install-precompiled-lua and install-precompiled-node targets 2023-12-15 10:30:49 +09:00
cm Update cmtool 2023-11-07 18:03:14 +09:00
docs Version 0.3.0 2025-10-12 21:09:07 +09:00
example Add MLB files to JavaScript examples 2025-10-12 18:27:23 +09:00
lib/lunarml checkpoint 2025-12-18 11:25:19 -03:00
package Version 0.3.0 2025-10-12 21:09:07 +09:00
pluto Use smlfmt 1.2.0 2025-05-31 11:42:00 +09:00
src checkpoint 2025-12-18 12:25:06 -03:00
test Test: Check the syntax of the resulting code for compile-only tests 2025-09-18 16:25:33 +09:00
thirdparty Support non-default annotations in the library 2023-10-09 16:52:50 +09:00
util Tweak code generation for records 2023-06-02 22:51:13 +09:00
.gitattributes Add 'archive' target 2023-12-14 21:51:17 +09:00
.gitignore Tweak Makefile 2025-09-01 22:12:02 +09:00
.readthedocs.yaml Docs: Use uv instead of rye 2025-02-10 22:29:56 +09:00
CHANGELOG.md Version 0.3.0 2025-10-12 21:09:07 +09:00
CLAUDE.md checkpoint 2025-12-18 10:47:09 -03:00
LICENSE Version 0.2.0 2024-08-06 22:02:04 +09:00
Makefile checkpoint 2025-12-17 19:34:22 -03:00
millet.toml checkpoint 2025-12-18 10:47:09 -03:00
README.md Version 0.3.0 2025-10-12 21:09:07 +09:00
set-version.sh Add 'archive' target 2023-12-14 21:51:17 +09:00
test_go.go checkpoint 2025-12-18 10:47:09 -03:00
test_go.lua checkpoint 2025-12-18 10:47:09 -03:00
test_go.sml checkpoint 2025-12-18 10:47:09 -03:00
test_go_simple.go checkpoint 2025-12-18 10:47:09 -03:00
test_go_simple.sml checkpoint 2025-12-18 10:47:09 -03:00
version.mk Version 0.3.0 2025-10-12 21:09:07 +09:00

LunarML

The Standard ML compiler that produces Lua/JavaScript.

The documentation is available at https://lunarml.readthedocs.io/en/latest/.

Trying pre-built binaries

If you obtained an archive named lunarml-{version}-{arch}-{os}.tar.gz:

$ tar xf lunarml-0.3.0-{arch}-{os}.tar.gz
$ cd lunarml-0.3.0
$ make install PREFIX=/opt/lunarml
$ export PATH=/opt/lunarml/bin:$PATH
$ lunarml compile example/hello.sml

Also, Docker image is available:

$ docker pull ghcr.io/minoki/lunarml:latest
$ docker run --rm -v "$(pwd)":/work -w /work ghcr.io/minoki/lunarml:latest lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!

In case you do not want to use Docker, there are precompiled scripts available in the tarball. You can use install-precompiled-lua target to install lunarml.lua which can be run with Lua 5.3/5.4 and LuaFileSystem.

$ make install-precompiled-lua PREFIX=/opt/lunarml
$ export PATH=/opt/lunarml/bin:$PATH
$ lunarml compile example/hello.sml

You can use install-precompiled-node target to install lunarml.mjs to be run with Node.js.

$ make install-precompiled-node PREFIX=/opt/lunarml
$ export PATH=/opt/lunarml/bin:$PATH
$ lunarml compile example/hello.sml

Warning: Script-compiled LunarML is slow. Use native binary for serious use.

Building and Installing

You need a recent version of MLton to build the executable, and Lua 5.3+ or recent Node.js to run the compiled script.

$ make
$ make test-lua
$ make test-lua-continuations
$ make test-luajit
$ make test-nodejs
$ make test-nodejs-cps
$ bin/lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!

You can install the built binary with make install:

$ make install PREFIX=/opt/lunarml
$ export PATH="/opt/lunarml/bin:$PATH"
$ lunarml compile example/hello.sml

Alternatively, you can use Docker to build and run LunarML.

$ docker build -f package/docker/Dockerfile -t lunarml:0.3.0 .
$ docker run --rm -v "$(pwd)":/work -w /work lunarml:0.3.0 lunarml compile example/hello.sml
$ lua example/hello.lua
Hello world!

Usage

lunarml compile [options] input.(sml|mlb)

Subcommands:

  • compile: Compile a program.
  • check: Type check only.
  • help: Show help.
  • version: Show version information.

Targets:

  • Lua
    • --lua (default): Targets Lua 5.3+.
    • --lua-continuations: Targets Lua 5.3+. Supports one-shot delimited continuations. Also, supports deeply nested handle.
    • --luajit: Targets LuaJIT.
  • JavaScript (ES2020+)
    • --nodejs: Produces a JavaScript program for Node.js. The default extension is .mjs.
    • --nodejs-cps: Produces a JavaScript program for Node.js (CPS mode; supports delimited continuations). The default extension is .mjs.
    • --webjs: Produces a JavaScript program for Web. The default extension is .js.
    • --webjs-cps: Produces a JavaScript program for Web (CPS mode; supports delimited continuations). The default extension is .js.

Output type:

  • --exe (default): Produces Lua/JavaScript program.
  • --lib: Produces a Lua/JavaScript module.

Features

  • Full SML '97 language, including signatures and functors
    • Note that some features conform to Successor ML rather than SML '97.
  • Successor ML features
  • Other language extensions
  • A subset of SML Basis Library
  • ML Basis system for multi-file project
  • Interface to Lua
  • Interface to JavaScript
  • Delimited continuations
  • Other libraries