... | @@ -30,3 +30,34 @@ Prelude> :t (1 -) |
... | @@ -30,3 +30,34 @@ Prelude> :t (1 -) |
|
|
|
|
|
> >
|
|
> >
|
|
> > If we removed special treatment of '-', then these become symmetrical again. However it seems unintuitive that `(-x)` is a right section of '-', but `(-1)` is the literal -1.
|
|
> > If we removed special treatment of '-', then these become symmetrical again. However it seems unintuitive that `(-x)` is a right section of '-', but `(-1)` is the literal -1.
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
Another motivation for lexing - as part of a numeric literal (or changing its precedence), from 2007-10-10 \#haskell:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
[09:33] < quicksilver> am I the only person who finds mod's behaviour with
|
|
|
|
negative numbers stupid
|
|
|
|
[09:34] < matthew-_> try rem then
|
|
|
|
[09:34] < quicksilver> > (-4) `mod` 16
|
|
|
|
[09:34] < quicksilver> > (-4) `rem` 16
|
|
|
|
[09:34] < lambdabot> 12
|
|
|
|
[09:34] < lambdabot> -4
|
|
|
|
[09:34] < quicksilver> that's odd, that's not what my ghci did
|
|
|
|
[09:34] < quicksilver> doh
|
|
|
|
[09:34] < quicksilver> bracketing error :P
|
|
|
|
[09:35] < quicksilver> mod does do what I expect, if I put the negative number
|
|
|
|
in bracets
|
|
|
|
[09:35] < quicksilver> I wouldn't expect 'unary minus' to have lower precedence
|
|
|
|
that `mod` though
|
|
|
|
[09:35] < sieni> > -4 `rem` 16
|
|
|
|
[09:35] < lambdabot> -4
|
|
|
|
[09:35] < sieni> oops
|
|
|
|
[09:35] < sieni> > -4 `mod` 16
|
|
|
|
[09:35] < lambdabot> -4
|
|
|
|
[09:35] < quicksilver> sieni: yeah, that's what I did
|
|
|
|
[09:36] < sieni> quicksilver: yeah I know, that has bitten me too :-)
|
|
|
|
[09:36] < quicksilver> I always expect unary minus to bind tight
|
|
|
|
[09:37] < osfameron> yeah, haskell's unary minus is surprisingly loose
|
|
|
|
``` |
|
|
|
\ No newline at end of file |