Home / Docs / Diagnostics
U7001: Non-canonical formatting
Release v0.4.0
A region of a file differs from the file's canonical form. una check compares each file with its canonical form and reports U7001 for every region that differs.
Why Una rejects it
Every Una program has one canonical form (ADR 0011, ADR 0020):
- two spaces per indentation level,
- one line per statement or clause,
- one space around binary operators,
- the short form for a function without clauses whose body is one line,
- constructor arguments in the order their fields are declared,
- sorted imports, and
- exactly one blank line between declarations.
A file with syntax errors is checked for U7001 once they are fixed.
How to fix it
una check reports each region with a mechanical edit that replaces the region. una fmt rewrites whole files, and una fmt --check reports without writing. The formatter keeps every comment on its line.
The repair at a glance
diff
module demo
- pub double(x: Int) -> Int
- =
- x * 2
+ pub double(x: Int) -> Int = x * 2Failing example
una
module demo
pub double(x: Int) -> Int
=
x * 2Fixed example
una
module demo
pub double(x: Int) -> Int = x * 2