[Haskell-cafe] Re: Unary Minus
DekuDekuplex at Yahoo.com
Mon Apr 6 06:04:17 EDT 2009
Interesting. How is this hack implemented?
I just checked the BNF grammar for the lexical syntax of Haskell in
"The Haskell 98 Language Report" (see the BNF grammer given under "9.2
Lexical Syntax" under "9 Syntax Reference" at
http://www.haskell.org/onlinereport/syntax-iso.html), but had
difficulty in deriving a unary minus.
Could somebody please enlighten me on how to derive the expression
"-1" (a unary minus followed the the ascDigit 1) from the
above-mentioned BNF grammar? Or is a unary minus not part of this
-- Benjamin L. Russell
On Mon, 6 Apr 2009 11:14:52 +0200, Lennart Augustsson
<lennart at augustsson.net> wrote:
>Unary minus is a hack in the syntax for allowing the function negate
>to be written as prefix -.
>On Mon, Apr 6, 2009 at 10:36 AM, Martijn van Steenbergen
><martijn at van.steenbergen.nl> wrote:
>> Paul Keir wrote:
>>> If I use :info (-) I get information on the binary minus. Is unary minus
>>> also a function?
>> No, as far as I know the unary minus is part of the number literals. You can
>> use "negate" if you want it as a function.
>> Hope this helps,
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
Benjamin L. Russell / DekuDekuplex at Yahoo dot com
Translator/Interpreter / Mobile: +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto."
-- Matsuo Basho^
More information about the Haskell-Cafe