[Haskell-beginners] Re: map question

Will Ness will_n48 at yahoo.com
Sat Oct 17 14:29:39 EDT 2009


Brent Yorgey <byorgey <at> seas.upenn.edu> writes:

> 
> By the way, the reason
> 
>   map (+1) [1,2,3,4]
> 
> works but
> 
>   map (-1) [1,2,3,4]
> 
> doesn't is because of an ugly corner of Haskell syntax: -1 here is
> parsed as negative one, rather than an operator section with
> subtraction.  The 'subtract' function is provided exactly for this
> purpose, so that you can write
> 
>   map (subtract 1) [1,2,3,4]
> 

Then why wouldn't (`-`1) parse at at all? And not even (`(-)`1) ?

I know this doesn't parse, my question is, why wouldn't it be made valid 
syntax? It seems consistent. (`mod`2) parses, why not (`-`2) ?






More information about the Beginners mailing list