# Sane haskell-mode indentation setup?

**URL:** <https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749>\
**Category:** Uncategorized\
**Created:** [August 15, 2025, 8:59pm UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749 "2025-08-15T20:59:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![torimus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/torimus/32/5234_2.png) [@torimus](https://discourse.haskell.org/u/torimus)\
**Post date:** [August 15, 2025, 8:59pm UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749/1 "2025-08-15T20:59:53Z")

</div>

Curious if anybody has already figured out satisfying (auto)indentation settings for coding in Emacs?

In accordance to common standard - basic indent of 4 spaces, 2 spaces indent for `where,`2 spaces after `where` and `let/in etc. Alternatively by `[Haskell Style Guide](https://kowainik.github.io/posts/2019-02-06-style-guide) .

I have in that sense configured external formatter `fourmolu`, which exactly does the job, but for the sake of me I can’t get the same within `haskell-mode`. Only partial results, both in default `haskell-indentation-mode` and `haskell-indent-mode`.

Can you share your setup or it is just not possible in current state of affairs. unless resort to own hacking in elisp?

---

<div class="post-metadata">

**Author:** ![sergv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sergv/32/4700_2.png) [@sergv](https://discourse.haskell.org/u/sergv)\
**Post date:** [August 15, 2025, 11:39pm UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749/2 "2025-08-15T23:39:16Z")

</div>

I’ve found Treesitter-based indentation to be much saner than hand-rolled parsers in the `haskell-mode`, which I attempted to extend and fix for the cases I cared about. Not being satisfied with available treesitter indentations I’ve made one for myself ([dotemacs/src/haskell/haskell-ts-indent.el at master · sergv/dotemacs · GitHub](https://github.com/sergv/dotemacs/blob/master/src/haskell/haskell-ts-indent.el) which plugs into [dotemacs/src/haskell/haskell-ts-mode.el at master · sergv/dotemacs · GitHub](https://github.com/sergv/dotemacs/blob/master/src/haskell/haskell-ts-mode.el)). Not sure how much effort you’d like to spend on setting it all up though.

However, haskell-mode indentations were pretty reasonable in last 10 years and still hold up well w.r.t. supported Haskell syntax features. Perhaps you’ll get better bung for the buck by identifying specific instances of indentation you don’t like and finding parameters that make them right.

---

<div class="post-metadata">

**Author:** ![Ambrose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ambrose/32/5672_2.png) [@Ambrose](https://discourse.haskell.org/u/Ambrose)\
**Post date:** [August 16, 2025, 6:13am UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749/3 "2025-08-16T06:13:46Z")

</div>

idk i’ve used stock for years

haskell-mode indent isn’t meant to automate your whitespace. it’s meant to facilitate it. you still have to be a smart human being with taste 🙂

manual indentation isn’t a sin

---

<div class="post-metadata">

**Author:** ![treblacy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/treblacy/32/1782_2.png) [@treblacy](https://discourse.haskell.org/u/treblacy)\
**Post date:** [August 17, 2025, 4:09pm UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749/4 "2025-08-17T16:09:01Z")

</div>

I use haskell-indentation-mode, and I set haskell-indentation-left-offset to 4. (Note: IIRC that “4” means e.g. 4 under “do”; some other defaults already ensure 2 for “where”, 2 more under “where”.)

It is already almost perfect and flexible. There are just a few corner cases I need to manually override.

---

<div class="post-metadata">

**Author:** ![unhammer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/unhammer/32/580_2.png) [@unhammer](https://discourse.haskell.org/u/unhammer)\
**Post date:** [August 22, 2025, 11:34am UTC](https://discourse.haskell.org/t/sane-haskell-mode-indentation-setup/12749/5 "2025-08-22T11:34:17Z")

</div>

Cool, that could probably go on melpa 🙂 (or even better get it merged into the official [GitHub - haskell/haskell-mode: Emacs mode for Haskell](https://github.com/haskell/haskell-mode) )
