[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-prime
Subject:    Re: Proposal: require spaces around the dot operator
From:       Gábor_Lehel <illissius () gmail ! com>
Date:       2012-02-11 17:16:23
Message-ID: CAPNUp0_ASk26HGHSs6gt5yzV9Wz9JbG2ZTqya2fs5k4BHyhGEg () mail ! gmail ! com
[Download RAW message or body]

On Sat, Feb 11, 2012 at 4:07 PM, Doug McIlroy <doug@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.

_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic