On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk <vandijk.r...@gmail.com> wrote:
>On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell ><dekudekup...@yahoo.com> wrote: >> Interesting. ?How is this hack implemented? > >This seems to be the relevant grammar: > lexp6 -> - exp7 > lpat6 -> - (integer | float) (negative literal) > >The '6's and the '7' are superscripts. >Perhaps the hack is in the precedence of the expression in which an >unary minus is allowed. What's interesting are the following definitions of the functions '-' (binary minus) and "negate" given in "8 Standard Prelude" (see http://www.haskell.org/onlinereport/standard-prelude.html#$tNum): >class (Eq a, Show a) => Num a where > (+), (-), (*) :: a -> a -> a > negate :: a -> a > abs, signum :: a -> a > fromInteger :: Integer -> a > > -- Minimal complete definition: > -- All, except negate or (-) > x - y = x + negate y > negate x = 0 - x The type of "negate," "a -> a", where a is a Num, is precisely what is needed for a unary minus. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe