Version 3 (modified by Simon Marlow, 12 years ago) (diff)

Eliminate tabs

Many newbies seems to get their Haskell code layout wrong because their editor uses tab stops that are not 8 spaces wide. The code looks to them exactly as if it were correctly aligned, but according to the Haskell Report it is not. A reasonable proposal would be to outlaw tab characters in source code altogether. Always use spaces for indentation. Most editors can automatically convert from tabs to spaces, and it is better to alert the newbie programmer with a lexical error "tab not permitted", than to leave it to either the parser, or worse, the type system, to complain about something incomprehensible later on.


[added by Simon M] An alternative suggestion is the following: make it an error if the meaning of any layout depends on the width of a tab character. More precisely, this means a requirement that every two adjacent indented lines must begin with the same sequence of spaces and tabs, up to the indentation of the least-indented line.


  • small change to the language
  • breaks very little code
  • allows tabs of any width to be used, and code created using one tab width still has the same meaning when viewed with a different tab width


  • more complicated to explain than just disallowing tabs altogether
  • more to implement