Fantomas vs Fourmolu
Fantomas
fsprojects.github.ioFourmolu
fourmolu.github.ioSide by side
| Figure | Fantomas | Fourmolu |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Web | Yes | Yes |
| Windows | Yes | Yes |
| macOS | Yes | — |
| Linux | Yes | Yes |
| Plans published | 1 | 1 |
| Spec score · Code Formatting Tools | 8.0 (#9) | 8.3 (#4) |
| Configuration | A limited set of formatting options can be stored in `.editorconfig` and read automatically by the command line tool. | Settings can be provided in a fourmolu.yaml file or as command-line options. |
| Purpose | Fantomas is an opinionated formatter for F# source code that formats files based on configuration. | Fourmolu formats Haskell source code and is a configurable fork of Ormolu. |
Plans
In their own words
Fantomas
Fantomas formats F# source code according to configuration, using default rules based on Microsoft’s F# style guide. Settings are also available for G-Research conventions. It runs as a .NET tool, and local installation is recommended when a repository needs to keep a fixed version. The command line accepts folders or files with `.fs`, `.fsi`, `.fsx`, `.ml` or `.mli` extensions; source files are expected to parse with the F# compiler before formatting. A limited selection of options can be placed in `.editorconfig` for automatic use by the command-line tool. For continuous integration checks, `dotnet fantomas check` reports formatting drift and exits with a failure code when files need formatting. Setup guides are available for JetBrains Rider, Visual Studio Code and Visual Studio, and the official site links to an online tool for trying the formatter and its settings. Fantomas and its library are available under the Apache 2.0 license. The project is described as an fsprojects incubation project. It is free and open source, with web access listed alongside Linux, macOS and Windows.
Fourmolu
Fourmolu is a configurable formatter for Haskell source code and a fork of Ormolu. It uses GHC’s parser and aims to keep diffs small, produce idempotent output, and handle large projects. Set formatting options in `fourmolu.yaml` or pass them on the command line. Controls include indentation, line length, import grouping, record layout, Haddock comments, Unicode output, and operator fixities. Fourmolu can find the relevant Cabal file to read default extensions and dependencies that help determine fixities. Magic comments can disable formatting for selected code, and command-line options can target a line region. There is an interactive browser demo with configurable formatting and program options. Installation instructions cover GHCup, Cabal, Stack, and dotslash; editor integration is documented through Haskell Language Server. The project recommends a GitHub Action to keep projects formatted. Its listed current release is v0.21.0.0. CPP handling is experimental and limited to simple cases where conditionals surround top-level declarations. Output always uses LF line endings, which can cause check mode to fail on CRLF files.