Proposal: require spaces around the dot operator

Doug McIlroy doug at
Sat Feb 11 16:07:37 CET 2012

> +1 to the idea of requiring spaces around all operators. 
> It's just good style

> Cutting things close syntactically just because you can is perhaps 
> not the best of ideas

Haskell is mathematical both in substance and style.  I would
not lightly prohibit the use of spacing conventions that have proved
over centuries to aid in understanding syntactic strucure.

For example, this code fragment to define addition on lists
is instantly intelligible.

instance Num a => Num [a] where
	(f:fs) + (g:gs) = f+g : fs+gs

But the formula becomes merely an obscure procession of symbols when 
rewritten with the operators set off by spaces:

	( fs : gs ) + ( g : gs ) = f + g : fs + gs

And it becomes too long and too subtly modulated to take in at
a glance if more spacing is added to emphasize precedence:

	( f : fs )  +  ( g : gs )   =   f + g   :   fs + gs

Doug McIlroy

More information about the Haskell-prime mailing list