v1.0.0 (Jan 10, 2023)
smlfmt
is a custom parser and code formatter for Standard ML.
Features
- Full support for Standard ML according to the formal definition.
- Fast -- see performance results below.
- Usable for large projects.
- Whole-project formatting via
.mlb
files using MLton conventions.
- Whole-project formatting via
- Helpful error messages with visual code references and syntax highlighting.
- Support for various SuccessorML syntax extensions.
- Configurable indentation size and maximum width.
Performance
smlfmt
is fast enough for live reformatting on large individual files, and can reformat large projects in seconds.
Here are measurements for smlfmt --preview-only INPUT > out
on my MacBook Air (M2, 2022).
Input | Size (LoC) | Time |
---|---|---|
src/prettier-print/PrettierExpAndDec.sml |
1024 | 31 ms |
src/base/PrettyTabbedDoc.sml |
1349 | 29 ms |
src/parse/ParseExpAndDec.sml |
1363 | 28 ms |
MLton elaborate-core.fun |
3942 | 104 ms |
MLton x86-allocate-registers.fun |
11034 | 216 ms |
Entire MLton source code (mlton.mlb ) |
160000 (approx.) | 6.6s |
(Timings are averages reported by hyperfine
.)