[Haskell-cafe] negate and -

Matthew William Cox matt at mattcox.ca
Thu May 17 13:07:56 EDT 2007


On Thu, 17 May 2007 13:50:15 -0300
Maurí­cio <briqueabraque at yahoo.com> wrote:

> Hi,
> 
> Haskell language reference says the special -
> operator translates to negate. However, this:
> 
> (+ negate 5) 5

Function application binds tightest, so this is equivalent to:
(+ (negate 5)) 5

> 
> works but this:
> 
> (+ -5) 5

In this context, it's trying to parse - as the binary subtraction operator. The special treatment of - in its unary context is that (-5) is (negate 5) and not the section ((-) 5)

> 
> is not valid. Why?
> 
> Thanks,
> Maurício
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


-- 
Matthew William Cox <matt at mattcox.ca>


More information about the Haskell-Cafe mailing list