Skip to content
ProgmasoftPublic

About

talafmt, the formatter of Tala: syntax-aware, parser-gated source formatting

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

talafmt

talafmt provides the talafmt command and validates every input with the canonical Tala lexer and parser before changing it. It normalizes line endings, trailing horizontal whitespace, the final newline, and brace-based block indentation. The compiler's lossless source-fragment model distinguishes code from comments, character literals, normal strings, and raw strings, so structural characters inside protected text never affect indentation.

talafmt is the formatter of Tala. It moved from the compiler repository with its history on 2026-10-18 and starts its own versions at 0.1.0.

The formatter accepts what the compiler it is built with accepts. Version 0.1.0 is built with the compiler of Tala 0.1.0, so a source may use method references (Type::Method), names written through their namespace, conditionals over strings, match, enums and console formats; none of them changes how a line is laid out.

talafmt Program.tala Library.tala
talafmt --check Program.tala Library.tala
talafmt --emit=stdout Program.tala
talafmt --help
talafmt --version

Without options talafmt formats every requested file in place and prints nothing. --check changes nothing and returns a failing exit status when any requested source would change. --emit=stdout, coverage, checkstyle and json write the formatted source or a report to standard output and leave the files alone; --emit=files is the default. -h and -v are the short forms of --help and --version. The command line is read by a typed parser written by hand; a line it cannot read exits with status 2. Project configuration is evaluated once for all requested sources.

The default engine uses four spaces per block level. Its public Haskell options also support tabs, an independent tab width, explicit LF or CRLF output, disabling reindentation, and preserving a missing final newline. Lines crossed by a multi-line raw string or long comment retain their payload indentation and trailing whitespace exactly; only their physical line ending changes when an explicit output ending is requested.

The Kotlin module under sources/main/kotlin owns the typed talafmt.kts configuration surface, canonical defaults, validation, immutable snapshots, and real scripting evaluator. talafmt invokes the installed talafmt-config helper once, then applies the selected input encoding, output encoding, and BOM policy to every requested source. Encoding is not a formatter CLI option: every talafmt run obeys talafmt.kts. UTF-16 and UTF-32 output uses deterministic little-endian payloads, with BOM emission controlled independently.

Building and testing

talafmt uses the compiler through the tala-tooling package. Until the compiler packages are on Hackage, cabal.project fetches them from Progmasoft/tala, pinned to the commit of the tala-0.1.0 release, so the first build compiles them too.

cabal update
cabal build all
cabal test all
.\gradlew.bat check      # the Kotlin configuration model: format check and tests

You need GHC 9.10 and Cabal 3.16, and JDK 25 for the Kotlin module.

Developer helpers

The Go programs in helpers run the same commands as CI: prebuild install sets up a host, develop check runs every gate, develop bundle packs a release archive for this host, and develop version and develop pin keep the version files and the pinned commits in order.

go run ./helpers/cmd/prebuild install
go run ./helpers/cmd/develop doctor
go run ./helpers/cmd/develop check

About

talafmt, the formatter of Tala: syntax-aware, parser-gated source formatting

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages