Wanted: warning option for usages of unary minus

Isaac Dupree isaacdupree at charter.net
Thu Apr 12 06:07:58 EDT 2007


-----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 alternatively you
>>> could implement the Haskell' proposal to remove prefix negation
>>> completely - treat the unary minus as part of a numeric literal in the
>>> lexer only.  This would have to be optional for now, so that we can
>>> continue to support Haskell 98 of course.
>>>
>>> Cheers,
>>>     Simon
> 
> Yes, I've been thinking about how to implement both - details will come
> later when I have more time.  I think I have a reasonably working idea
> of how to divide up the cases for warnings for ambiguous-looking use of
> both infix and prefix minus, as well as actual syntax changes...

not considering warnings, just syntax:  123abc is two valid Haskell
tokens. for example:
\begin{code}
main = (\n c -> print (n,c)) 123Abc
data Abc = Abc deriving Show
\end{code}
prints (123,Abc).
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 ...

Presently, GHC doesn't even warn about the first thing (123abc) ^_^


Isaac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGHgT9HgcxvIWYTTURAmhLAJ0Zwd8fRYWRIWDjsTRaPx84x80RBwCgjsMA
RxcCEg+2T/fraJmnsBYVEhE=
=HsSp
-----END PGP SIGNATURE-----


More information about the Glasgow-haskell-users mailing list