Re: Wanted: warning option for usages of unary minus

2007-05-21 Thread Simon Marlow
John Meacham wrote: On Mon, May 14, 2007 at 10:19:07AM +0100, Simon Marlow wrote: Really? I'm beginning to have second thoughts about the proposed change to negation for Haskell'. The main reason, and this isn't pointed out as well as it should be on the wiki, is that x-1 will cease to be an

Re: Wanted: warning option for usages of unary minus

2007-05-21 Thread John Meacham
On Mon, May 21, 2007 at 10:33:56AM +0100, Simon Marlow wrote: I think that we could easily remove the '3e4' lexical syntax though, since '3*10^^4' works just as well (I often write the latter anyway) (and guess what, I just had to look up the difference between ^ and ^^, only to discover I

Re: Wanted: warning option for usages of unary minus

2007-05-19 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John Meacham wrote: another option would be to only count it as a negative if there is a non-identifier character preceeding it. A little ugly. but still better than the current situation IMHO. I think Ghc's lexer Alex can do this although this

Re: Wanted: warning option for usages of unary minus

2007-05-18 Thread John Meacham
On Mon, May 14, 2007 at 10:19:07AM +0100, Simon Marlow wrote: Really? I'm beginning to have second thoughts about the proposed change to negation for Haskell'. The main reason, and this isn't pointed out as well as it should be on the wiki, is that x-1 will cease to be an infix

Re: Wanted: warning option for usages of unary minus

2007-05-18 Thread John Meacham
On Thu, May 17, 2007 at 06:40:04PM +0200, Twan van Laarhoven wrote: Simon Marlow wrote: ... Really? I'm beginning to have second thoughts about the proposed change to negation for Haskell'. The main reason, and this isn't pointed out as well as it should be on the wiki, is that x-1 will

Re: Wanted: warning option for usages of unary minus

2007-05-17 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Iavor Diatchki wrote: Hello, I agree with Simon on this one: x-1 should parse as expected (i.e., the infix operator - applied to two arguments x and 1). Having this result in a type error would be confusing to both beginners and working Haskell

Re: Wanted: warning option for usages of unary minus

2007-05-17 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I wrote: negative :: Num a = Integer - a negative a = fromInteger (negate a) Oops, I forgot Rational literals, they make things a little more complicated :( Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using

Re: Wanted: warning option for usages of unary minus

2007-05-17 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Twan van Laarhoven wrote: There is one other alternative for parsing: - is a unary minus if and only if it is a) preceded by whitespace or one of [({;,, and b) not followed by whitespace. So: x - 1 ==(-) x 1 x-1

Re: Wanted: warning option for usages of unary minus

2007-05-14 Thread Simon Marlow
John Meacham wrote: On Wed, Apr 11, 2007 at 09:05:21AM +0100, Simon Marlow wrote: I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of prefix negation, or

Re: Wanted: warning option for usages of unary minus

2007-05-14 Thread Iavor Diatchki
Hello, I agree with Simon on this one: x-1 should parse as expected (i.e., the infix operator - applied to two arguments x and 1). Having this result in a type error would be confusing to both beginners and working Haskell programmers. I think that if we want to change anything at all, we

Re: Wanted: warning option for usages of unary minus

2007-05-07 Thread John Meacham
On Wed, Apr 11, 2007 at 09:05:21AM +0100, Simon Marlow wrote: I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of prefix negation, or alternatively you

Re: Wanted: warning option for usages of unary minus

2007-05-01 Thread Isaac Dupree
Okay, first steps: 1. A Trac ticket (#1318, http://hackage.haskell.org/trac/ghc/ticket/1318) (is feature request a good category, versus task?) 2. A test-case to make sure I don't break anything with existing '-' syntax. I'm guessing it should go in testsuite/tests/ghc-regress/parser/should_run/,

Re: Wanted: warning option for usages of unary minus

2007-04-12 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Isaac Dupree wrote: Simon Marlow wrote: I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of prefix negation, or

Re: Wanted: warning option for usages of unary minus

2007-04-12 Thread Simon Marlow
Isaac Dupree wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Isaac Dupree wrote: Simon Marlow wrote: I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of

Re: Wanted: warning option for usages of unary minus

2007-04-12 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simon Marlow wrote: So does this suggest that under a negation-is-part-of-numeric-token regime, 123-456 should be two tokens (a positive number then a negative number, here), as is signum-456 ... Yes, absolutely. [see note 1 at the end

Re: Wanted: warning option for usages of unary minus

2007-04-12 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Er, For the purpose of warnings, I would explicitly keep track, for unqualified operator -, whether it was followed by a digit (which is the unique and certain determiner that a numeric literal follows. Octal and hexadecimal start with 0c for

Re: Wanted: warning option for usages of unary minus

2007-04-11 Thread Simon Marlow
I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of prefix negation, or alternatively you could implement the Haskell' proposal to remove prefix negation

Re: Wanted: warning option for usages of unary minus

2007-04-11 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simon Marlow wrote: I definitely think that -1# should be parsed as a single lexeme. Presumably it was easier at the time to do it the way it is, I don't remember exactly. I'd support a warning for use of prefix negation, or alternatively you

Re: Wanted: warning option for usages of unary minus

2007-04-08 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Now I understand why negative unboxed numeric literals are parsed weirdly, after poking around a little! The parser parses all infix applications as right-associative, regardless of fixity.

Wanted: warning option for usages of unary minus

2007-04-07 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Since the unary negation operator `-' is often considered a wart in Haskell's syntax and in many cases saying negate is arguably clearer anyway, I propose adding options to GHC to warn about its use. The only case I don't normally want to be warned