Proposal: require spaces around the dot operator
Gábor Lehel
illissius at gmail.com
Sat Feb 11 18:16:23 CET 2012
On Sat, Feb 11, 2012 at 4:07 PM, Doug McIlroy <doug at cs.dartmouth.edu> wrote:
> 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
I wouldn't require them inside parentheses, but that's a very good
point: the list constructor in patterns is an example of an operator
where basically no one ever uses spaces.
>
> 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
I would rather write (f + g) : (fs + gs), but point taken.
In any case, while I would in theory support spaces around all
operators, modulo counterexamples such as those presented above, I'm
not proposing it and I don't think anyone is, so it's probably best to
stick to discussing spaces around (.) (which I also support).
Apologies for taking the discussion off topic.
More information about the Haskell-prime
mailing list