[Haskell-cafe] Re: [Haskell-beginners] map question

wren ng thornton wren at freegeek.org
Mon Oct 19 21:02:29 EDT 2009


Will Ness wrote:
> wren ng thornton writes:
>> Attack the underlying problem, don't introduce hacks to cover up broken 
>> hacks. This isn't C++.
> 
> The underlying problem is a broken scanner where it can't distinguish between a 
> binary op and a number read syntax.

The underlying problem is that (1) people don't want "normal" whitespace 
to change the meaning of code, (2) they don't want to disallow negative 
literals, and (3) they want to use the same symbolic operator for 
negation and subtraction, but these three goals cannot all be satisfied 
simultaneously.

The current resolution is to hack at the parser in order to make things 
mostly work. But this hack is insufficient, as argued by the OP. The 
proposed solution was to introduce new syntax complicating the language 
by explaining how 1-2 and 1`-`2 are the same thing (either repeated for 
all other symbolic operators, or exceptional to the subtraction 
operator, and ugly by either approach). But why should we introduce all 
this syntactic complexity which needs explaining to newbies and only 
makes the wart more visible?

The proper solution is not to introduce syntactic hackery on top of the 
parser hackery, the proper solution is to either come up with a better 
parser hack or to sacrifice one of the three incompatible goals.


> Not a hack, a solution. A consistent one. Look:
> 
>   (`foldl` 0)
>   (`-` 2)
> 
> Don't they look exactly the same?

Not to me they don't. Symbolic and lexical operators are treated 
differently in Haskell. Considering all the places where they're treated 
differently, I see no compelling reason to think they should be 
considered similar here.

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list