
17 Oct
2009
17 Oct
'09
2:29 p.m.
Brent Yorgey
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) ?