Documentation
Formatting
Iris includes a formatter for PureScript. Run iris format to format a Spago workspace, check formatting in CI, or format a file without a workspace. You can also format an open document in your editor.
Format a workspace#
To format a workspace, run iris format from a directory inside it:
iris formatIris formats the src and test sources of every workspace package and writes changes in place. It skips downloaded dependencies in .spago, symlinks, nested workspaces, and files outside package sources. Formatting does not fetch dependencies or compile the workspace.
Check formatting in CI#
To check formatting without changing files, add --check:
iris format --checkIris lists files that need formatting on standard error and exits with status 1. It exits with status 0 when all files are formatted, or status 2 for an error such as invalid source or options.
Format a single file#
Use --file to format a single file. The formatted source code is printed to standard output.
iris format --file src/Main.pursUse --write to update the file and --check to check it. You can repeat --file to select multiple files. --write cannot be used with --check and vice versa.
If you use --file for multiple distinct inputs, add either --write or --check.
iris format --write --file src/Main.purs --file test/Main.pursUse --file - to read from standard input.
cat src/Main.purs | iris format --file -Format in your editor#
When your editor is connected to the Iris language server, the editor's Format Document command formats the open document, including unsaved changes. It uses the same formatter as iris format.
The editor sends tabSize to set the indentation width, which may differ from the command-line default of two spaces. Iris uses spaces even when insertSpaces is false. The editor preserves existing ASCII and Unicode spellings; it cannot enable the command-line --unicode option.
To match the command-line indentation in Visual Studio Code, add these settings for PureScript files to settings.json:
{ "[purescript]": { "editor.tabSize": 2, "editor.detectIndentation": false }}The preferred line width defaults to 100 columns. LSP clients that send custom formatting options can set options.lineWidth to a positive integer. The Visual Studio Code extension does not send this option. Iris returns no edits for invalid source.
Options and layout#
On the command line, Iris defaults to a preferred width of 100 columns and two spaces per indentation level. Set these options on the command line:
iris format --width 100 --indent 4 --unicode--width COLUMNSsets the preferred line width to a positive integer. Long comments and indivisible tokens can exceed it.--indent SPACESsets the indentation width from 1 to 65535 spaces.--unicodeuses Unicode for built-in signatures, arrows, constraints, andforall. Without it, Iris preserves the original spellings, including Unicode. The flag does not convert literals, comments, record labels, or user-defined operators.
Iris has no project-level formatter configuration. Use the same options when formatting and checking a project. Iris normalizes CRLF line endings in whitespace and comments to LF, so --check can report a CRLF file as needing formatting.
Iris sorts imports by module name, placing an open, unaliased import Prelude first. It does not sort or merge import lists. For example, given this file:
module Main where import Effectimport Prelude main :: Effect Unitmain= pure unitIris produces:
module Main where import Prelude import Effect main :: Effect Unitmain = pure unitThe formatter wraps expressions, types, and lists to fit the preferred width. It preserves comments and section separation outside the import block. For the full layout conventions, see the formatter reference.
Iris validates every result before writing any files. If a file has invalid source, Iris stops without writing any files. Writes are not atomic, so an interrupted or failed write can leave a file partially written or an earlier file already updated.