[commit: ghc] master: Improve docs for -XNegativeLiterals (33c880b)
git at git.haskell.org
git at git.haskell.org
Thu Aug 29 17:45:53 CEST 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/33c880b43ed72d77f6b1d95d5ccefbd376c78c78/ghc
>---------------------------------------------------------------
commit 33c880b43ed72d77f6b1d95d5ccefbd376c78c78
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu Aug 29 13:01:16 2013 +0100
Improve docs for -XNegativeLiterals
>---------------------------------------------------------------
33c880b43ed72d77f6b1d95d5ccefbd376c78c78
docs/users_guide/glasgow_exts.xml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 7a1af04..6c4046e 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -446,13 +446,18 @@ Indeed, the bindings can even be recursive.
The literal <literal>-123</literal> is, according to
Haskell98 and Haskell 2010, desugared as
<literal>negate (fromInteger 123)</literal>.
- </para>
-
- <para>
The language extension <option>-XNegativeLiterals</option>
means that it is instead desugared as
<literal>fromInteger (-123)</literal>.
</para>
+
+ <para>
+ This can make a difference when the positive and negative range of
+ a numeric data type don't match up. For example,
+ in 8-bit arithmetic -128 is representable, but +128 is not.
+ So <literal>negate (fromInteger 128)</literal> will elicit an
+ unexpected integer-literal-overflow message.
+ </para>
</sect2>
<sect2 id="num-decimals">
More information about the ghc-commits
mailing list