<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj" -->

---
title: Tilia—a new formatter for Haskell | daily.dev
description: A new Haskell source code formatter called Tilia has launched on Hackage, tackling three long-standing challenges in Haskell formatting: comment handling,...
canonical: https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Tilia—a new formatter for Haskell | daily.dev
og:description: A new Haskell source code formatter called Tilia has launched on Hackage, tackling three long-standing challenges in Haskell formatting: comment handling,...
og:url: https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj
og:image: https://api.daily.dev/og/posts/JWmNcEuYJ.png
og:image:alt: Tilia—a new formatter for Haskell
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Tilia—a new formatter for Haskell

**[Lobsters](https://daily.dev/sources/lobsters)** · 10 min read · 0 upvotes · 0 comments

## Summary

A new Haskell source code formatter called Tilia has launched on Hackage, tackling three long-standing challenges in Haskell formatting: comment handling, operator fixity inference, and CPP preprocessor support. Rather than hardcoding operator precedence, Tilia integrates with GHC and Cabal to derive exact fixities from interface files or source tarballs, tracking re-exports, namespace-specific fixities, and export children. For CPP, it enumerates configurations, formats each independently, and merges the results using ideas borrowed from the choice calculus, reintroducing conditional directives only where formatted outputs actually diverge. The author considers CPP support the most fragile part and plans further work on it. The project is available via Cabal component-based CLI commands, works with Nix and Stack projects, and has an accompanying GitHub Action.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://markkarpov.com/post/announcing-tilia.html>

## Questions this post answers

### How does Tilia figure out the correct fixity of custom Haskell operators when formatting code?

Tilia integrates directly with GHC and Cabal to read real fixity information instead of hardcoding a database. If a dependency is already installed, it reads GHC interface files; otherwise it downloads the source tarball via Cabal. It also tracks re-exports, export children like data constructors brought in by T(..), and namespace-specific fixities, reporting an ambiguity rather than guessing when multiple operators share a spelling.

_Developers weighing formatter accuracy against tutorials and comparisons can track releases like this on daily.dev._

### How does a Haskell formatter handle CPP conditional compilation directives without a CPP-aware parser?

Tilia enumerates every CPP configuration of a module, blanks out lines absent from each configuration, and feeds each resulting variant into GHC's normal parser since no CPP remains. It renders each configuration to an intermediate document representation, then merges the results using choice-calculus-style equational rules, reinserting #if directives only around the exact spots where formatted outputs actually differ.

_Anyone tracking new approaches to CPP-aware tooling can follow Haskell ecosystem updates on daily.dev._

### Where can I download or try the Tilia Haskell formatter?

Tilia's first release is published on Hackage, with its source hosted in a GitHub repository under mrkkrp/tilia where bugs can be reported. A companion GitHub Action, mrkkrp/setup-tilia, is also available for running the formatter in CI. The CLI supports commands like 'tilia inplace' and 'tilia check' scoped to Cabal components.

_Developers adopting new Haskell tooling can follow project releases like Tilia on daily.dev._

## Community take

How the wider developer community reacted, aggregated from 2 discussions and 10 comments across lobsters, hackernews (as of 2026-09-18).

**TL;DR:** Commenters are glad to finally see a Haskell formatter with real CPP support and cabal-component-based operation, while others question the formatting style choices, ask how comment/trivia handling works, and probe why operator fixity even matters for formatting.

**Sentiment:** 40% positive · 45% mixed · 15% skeptical

**The case for**

- CPP preprocessor support is seen as a long-missing, welcome feature.
- Operating on cabal components rather than individual files is praised as an improvement.
- Knowing operator precedence lets a formatter remove unnecessary parentheses and gain more layout flexibility.

**The pushback**

- Some dislike the enforced non-leading-comma style and the lack of configuration options.
- Unclear how the tool handles comments/trivia since the underlying parser reportedly doesn't return trivia nodes.
- Questions remain about whether it works offline given its reliance on Cabal to resolve dependencies.

**By community**

- lobsters (mixed): Enthusiasm for CPP support and cabal-component operation is tempered by style complaints, curiosity about comment handling, and questions about the relationship to Ormolu/Fourmolu.
- hackernews (mixed): No discussion content was provided beyond the story listing.

**Hottest debate:** Whether operator fixity information is actually necessary for formatting versus just useful for removing redundant parentheses.

**Open questions**

- How exactly does the tool preserve comments given that the underlying parser doesn't seem to expose trivia nodes?
- What is the relationship between this project and the author's earlier Ormolu work, and what is the current status of Ormolu and Fourmolu?
- Can the tool be used fully offline, or does it always need to query Cabal for dependency information?

**Highlights**

> The cool things: CPP support, and operating on cabal components instead of files. Finally!   The uncool things: « Admit no configuration » and uses the style that I personally don't like...... Never met anyone in person who actually prefers definitions with non-leading comma, why are there so many (two) haskell formatters that are opinionated about that What I don't get: why does one even need to know operator precedence to format? I don't think changing indentation or linebreaks can insert brackets or otherwise affect the meaning (outside of making the program stop compiling)
> — [morj on lobsters · 4 points, 1 comments](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell#c_xnhhqq)

> So what happened to [the Ormolu refactor that fixed everything](https://web.archive.org/web/20260819093310/https://markkarpov.com/post/ormolu-one-refactor-that-fixed-everything.html), which is also by Mark Karpov? Is this project a further development of that? What's the status or Ormolu and Fourmolu?
> — [janus on lobsters · 5 points, 1 comments](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell#c_ae4ey3)

> The post omits this detail, but I'm really curious how they handle trivia/comments. Especially seeing how the underlying parser library doesn't seem to return trivia nodes.
> — [wffl on lobsters · 2 points, 2 comments](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell#c_50xomw)

> knowing operator precedence lets you remove spurious parens. It's also nice in that you can then use the "proper" tree ordering to have more flexibility in formatting (I... think).  Black for example will add parens to your code in some cases to resolve line length issues. I think without operator precedence you end up with very few solutions
> — [rtpg on lobsters · 1 points](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell#c_uvaw5d)

> Is it possible to use it offline? (I tend to restrict my main editor to not have net connection)
> — [Sanity on lobsters · 1 points, 1 comments](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell#c_vqvocv)

**Source threads**

- [lobsters](https://lobste.rs/s/jbxpqz/tilia_new_formatter_for_haskell) · 17 points · 10 comments
- [hackernews](https://news.ycombinator.com/item?id=49740628) · 2 points · 0 comments

## Similar posts on daily.dev

- [A technical vision for the Haskell ecosystem](https://daily.dev/posts/a-technical-vision-for-the-haskell-ecosystem-vy0hywfpm) · Hacker News · 0 upvotes · 0 comments
- [Haskell \(Libraries\)](https://daily.dev/posts/haskell-libraries--umqiideey) · Lobsters · 0 upvotes · 0 comments
- [Haskell Language Server 2.15.0.0 release](https://daily.dev/posts/haskell-language-server-2-15-0-0-release-5g0v5xolp) · The Haskell Programming Language Blog · 0 upvotes · 0 comments
- [Issue 547](https://daily.dev/posts/issue-547-eidkozx95) · Haskell Weekly · 0 upvotes · 0 comments
- [Topiary: Formatting Forests](https://daily.dev/posts/topiary-formatting-forests-a2qg3hip8) · Planet Haskell · 0 upvotes · 0 comments

---

Tags: [#haskell](https://daily.dev/tags/haskell)

[View this post on daily.dev](https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Tilia—a new formatter for Haskell","url":"https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj"},"datePublished":"2026-09-18T02:38:19.220Z","dateModified":"2026-09-18T03:27:13.973Z","description":"A new Haskell source code formatter called Tilia has launched on Hackage, tackling three long-standing challenges in Haskell formatting: comment handling,...","image":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","thumbnailUrl":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"haskell","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Tilia—a new formatter for Haskell"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/tilia-a-new-formatter-for-haskell-jwmnceuyj#faq","mainEntity":[{"@type":"Question","name":"How does Tilia figure out the correct fixity of custom Haskell operators when formatting code?","acceptedAnswer":{"@type":"Answer","text":"Tilia integrates directly with GHC and Cabal to read real fixity information instead of hardcoding a database. If a dependency is already installed, it reads GHC interface files; otherwise it downloads the source tarball via Cabal. It also tracks re-exports, export children like data constructors brought in by T(..), and namespace-specific fixities, reporting an ambiguity rather than guessing when multiple operators share a spelling. Developers weighing formatter accuracy against tutorials and comparisons can track releases like this on daily.dev."}},{"@type":"Question","name":"How does a Haskell formatter handle CPP conditional compilation directives without a CPP-aware parser?","acceptedAnswer":{"@type":"Answer","text":"Tilia enumerates every CPP configuration of a module, blanks out lines absent from each configuration, and feeds each resulting variant into GHC's normal parser since no CPP remains. It renders each configuration to an intermediate document representation, then merges the results using choice-calculus-style equational rules, reinserting #if directives only around the exact spots where formatted outputs actually differ. Anyone tracking new approaches to CPP-aware tooling can follow Haskell ecosystem updates on daily.dev."}},{"@type":"Question","name":"Where can I download or try the Tilia Haskell formatter?","acceptedAnswer":{"@type":"Answer","text":"Tilia's first release is published on Hackage, with its source hosted in a GitHub repository under mrkkrp/tilia where bugs can be reported. A companion GitHub Action, mrkkrp/setup-tilia, is also available for running the formatter in CI. The CLI supports commands like 'tilia inplace' and 'tilia check' scoped to Cabal components. Developers adopting new Haskell tooling can follow project releases like Tilia on daily.dev."}}]}
```

