Skip to content

Instantly share code, notes, and snippets.

@ttuegel
Last active February 15, 2016 23:06
Show Gist options
  • Save ttuegel/4cb9d3809fc4263c3608 to your computer and use it in GitHub Desktop.
Save ttuegel/4cb9d3809fc4263c3608 to your computer and use it in GitHub Desktop.
Indentation pains in haskell-mode for Emacs

Electric indentation for parentheses, brackets, braces, commas, semicolons...

This isn't an issue of what I want, but rather when I want it. haskell-mode knows how to indent these things correctly, but I had to turn off electric indentation in haskell-mode because it does stupid things the rest of the time.

Concretely, I want a haskell-mode that knows how to be electric when there's only one "right" choice and that doesn't do stupid things when there are multiple possibilities.

Constraints

(I'll use | for the cursor.)

Before:

foo :: (Eq a, Num a)
=>|

After:

foo :: (Eq a, Num a)
       =>|

What I wanted:

foo :: (Eq a, Num a)
    =>|

In other words, => is an arrow like ->, I want it indented that way :) I concede, this is a matter of taste. I don't mind having to set some option to pick this style, but AFAIK there is no such option.

where after do { ... }

haskell-mode seems unaware that blocks with explicit braces (do { ... }, let { ... }, etc.) can be followed by where clauses just like layout-sensitive blocks.

Before:

foo bar baz =
  do { quux <- bar baz
     }
where|

After: no change (it refuses to indent)

What I wanted:

foo bar baz =
  do { quux <- bar baz
     }
  where|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment