[Haskell-cafe] Strange subtract operator behavior

John Meacham john at repetae.net
Tue Oct 16 21:10:51 EDT 2007


On Tue, Oct 16, 2007 at 06:27:19PM -0300, Isaac Dupree wrote:
> Peter Verswyvelen wrote:
> >Personally I could also live with allowing no space between the minus 
> >sign and the number... If you leave a space, - becomes the subtract 
> >operator.
> 
> I once thought that... there was the opposition that (x-1) subtraction 
> of a constant appears too often.  And I found that I myself wrote that 
> several times.  And saying "whitespace on the left but not the right" 
> seems too complicated for Haskell lexer semantics.  So the current 
> situation is just unhappy, that's all. (and maybe compiler warnings 
> could still be implemented)

not just unhappy, but inefficient. 
-10 tranlates to (negate (fromInteger 10)) requiring 2 indirect class
calls rather than what one might expect (fromInteger -10)

also, negate in Num is sort of ugly IMHO. It would be nice if it wern't
there. Things like naturals have a perfectly reasonable subtract, but no
negate.

I think losing x-1 would be worth it. but I know there were some other
ideas out there that might be preferable but could still be handled at
the lexing stage rather than the parsing one...  

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list