Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fourmolu Migration

Decided2026-02-12
Decided byPaolo Veronelli

Why

The project previously used stylish-haskell for formatting imports and language pragmas. However, stylish-haskell only handled a narrow subset of formatting concerns — it did not format function definitions, type signatures, expressions, or any other code outside of imports and pragmas. This left most formatting decisions to manual convention enforcement.

Fourmolu is a full-source Haskell formatter that handles all code, not just imports. Adopting it eliminates formatting discussions during code review and ensures consistent style across the entire codebase.

Decision

Replace stylish-haskell with fourmolu as the project's code formatter. Configuration is in fourmolu.yaml at the repository root.

Key settings:

comma-style: leading
function-arrows: leading
import-export-style: leading
indentation: 4
column-limit: 70
haddock-style: single-line
record-brace-space: false
respectful: true

This supersedes the stylish-haskell section in Coding Standards.

Rationale

  • Full coverage: fourmolu formats all Haskell source code, not just imports and pragmas
  • Deterministic: running fourmolu --mode inplace on any file produces canonical output, eliminating formatting debates
  • Leading style: the leading commas/arrows setting aligns with the project's existing variable-length indentation avoidance policy
  • 70-character column limit: slightly narrower than the historical 80-character guideline, producing more readable diffs

References