
9 Sep
2007
9 Sep
'07
3:28 p.m.
On Sun, 9 Sep 2007, Peter Verswyvelen wrote:
I find it unfortunate that one can't (I guess) define custom unary operators in Haskell.
Incidentally, the nhc98 compiler has always permitted the definition of unary operators, as an extension to the language. (It was just more convenient to create a general mechanism for unary/prefix operators, than to code the special case for negative numbers.) The definition syntax is rather like for infix decls: infixl 6 + prefix negate 6 - -- WARNING Not standard Haskell The operator symbol (-) is bound to a function name (negate), and has a precedence just like infix operators. Regards, Malcolm