AW: Editor Tab Expansion

Ingo Wechsung
Fri, 6 Dec 2002 12:09:46 +0100

Andrew wrote:

>My remark was merely in response to the claim that Haskell cares
>whether you put tabs or spaces in your files.  It does not, so long
>as the tabs are of length 8.  If your editor produces tabs of a
>different size, that's a problem with your editor or the way you
>dislike Haskell's layout rules.

No. My editor produces the ASCII code for horizontal tab, when I hit the tab
Just as it produces the ASCII code for a when I hit the a key.

That's how it should be.

The real problem is, that nobody could tell from just looking at the screen,

what a program means even if you know the layout rules very well. The reason
that the Haskell lexer sees tabs while you cannot see tabs 
unless you use a hex editor. 
Instead, your text editor displays some space in place of the tab. 
Only if the expansion rules of your editor are compatible with Haskell's may

you grasp the source codes meaning. But, again, you can't know that by just
at the screen.

You have to use the :l command or the :se command in vi, for example, to
make sure

a) there are either only tabs or only spaces in front of the lines
or b) the editor lets you view tabs expanded to 8.

Or, to turn it another way: "What you see is not necessarily what you get".
This may be fine for ad hoc scripts that one examines in hugs.

But how can one hope to convince people that this is a good thing for
reusable code, to be compiled code, serious software production! 
I mean business. Teams. Maintenance of code that has been written by 
someone else, etc.

Some people suggested that the editor be configured so that it converts
all tabs to spaces or vice versa on file open. Beware!
Think of a software development team. One member (in India) uses 
"convert n leading spaces to tabs", the other (in Japan)
"convert leading tabs to m spaces". Everytime one of them makes a small
in a file that has been changed by the other before, the source code control
system will have a huge diff. Because, you can't use diff -b (ignore leading
space in comparision) on Haskell source. That implies that you cannot see
what this small change was. Instead, every indended line will be displayed
as changed.
This is a NIGHTMARE for project leaders, quality assistance staff, code