Source

Fed up with pressing TABs hundreds times a day in Haskell programming with the offside rule, I wrote a small elisp:
http://bitbucket.org/camlspotter/offside-trap/src
This elisp understand nothing about Haskell. It just traps each indentation change of one line, and extends it to its “sticky” lines. Sticky lines are:
- It is below of the cursor line or another sticky line
- Its indentation is as deep as or deeper than the cursor line.
The rule is simple but works nicely:
-------------------------------------------------------------------------
hoge = case hoge of
[]Foo -> hogehoge <= The cursor ([]) is here
Bar -> let x = hogehoge in <= Sticky
poo poo <= Sticky
_ -> error "bang" <= Sticky
huga = 2 <= Not sticky
-------------------------------------------------------------------------
Pressing ONLY ONE TAB, I got the following. Puff!:
-------------------------------------------------------------------------
hoge = case hoge of
[]Foo -> hogehoge
Bar -> let x = hogehoge in <= Sticky
poo poo <= Sticky
_ -> error "bang" <= Sticky
huga = 2 <= Not sticky
-------------------------------------------------------------------------
Of course this “offside trap” only works against codes with correct indentations. But it definitely improved my Haskell coding experience.
Jun