2 unstable releases
new 0.2.0 | Feb 26, 2025 |
---|---|
0.1.0 | Feb 23, 2025 |
#581 in Development tools
68 downloads per month
89KB
2K
SLoC
tlafmt
A formatter for TLA+ specs.
It looks like this:
Add(t, k, v) == \* Using transaction t, add value v to the store under key k.
/\ t \in tx
/\ snapshotStore[t][k] = NoVal
/\ snapshotStore' = [snapshotStore EXCEPT ![t][k] = v]
/\ written' = [written EXCEPT ![t] = @ \union {k}]
/\ UNCHANGED << tx, missed, store >>
Some TLA specs are hand-crafted works of art - but not all of them - this tool is for those ugly specs!
- Optimises for easily readable output.
- Consistent formatting across different teams and authors.
- Helpful but not forceful - small tweaks, not big rewrites!
- Fast rendering - suitable for "format on save" in interactive editors.
Install
Download pre-built binaries from the releases page.
Or if you have Rust installed, compile it yourself: cargo install tlafmt
.
Usage
Format a file and print the formatted result to stdout:
% tlafmt bananas.tla
Or overwrite the input file with the formatted result:
% tlafmt --in-place bananas.tla
To check if a file is formatted and return an error if it isn't, use --check
:
% tlafmt --check bananas.tla
# Exits code 3 for unformatted code.
Check out the --help
text too.
Dependencies
~53MB
~1M SLoC