Version 2 (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. Adopting this style in source code is already recommended in the report (section 9.3, "to avoid visual confusion…"), the proposal is to change this guideline into a requirement.


  • 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