summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2014-06-21 11:38:17 +0200
committerHerbert Valerio Riedel <hvr@gnu.org>2014-06-27 20:46:32 +0200
commit1c0b5fdc9f2b6ea8166cc565383d4cd20432343c (patch)
tree52a6c1679d03672ff4e03c22642ad0b876d5ed51 /docs
parentf4766c4b4ad10ef7c58bc6b443ec244a07c68bf5 (diff)
downloadhaskell-1c0b5fdc9f2b6ea8166cc565383d4cd20432343c.tar.gz
Add -XBinaryLiterals language extension (re #9224)
Haskell2010 supports - base-10 (prefix-less), - base-8 (via `0[oO]`-prefix), and - base-16 (via `0[xX]`-prefix) integer literals. This commit adds syntax support for base-2 integer literals via the new `0[bB]` prefix. The use of a `0b` prefix for indicating binary literals is known from popular programming languages such as C++14, Perl, Python, Ruby, and Java. This syntax extension is disabled by default and can be enabled via the new `{-# LANGUAGE BinaryLiterals #-}` pragma and/or the new `-XBinaryLiterals` This new extensions requires to upgrade the `ExtsBitmap` type from `Word` to `Word64` as this adds a 33th flag which is not guaranteed to fit into a `Word`. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org> Differential Revision: https://phabricator.haskell.org/D22
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/7.10.1-notes.xml2
-rw-r--r--docs/users_guide/flags.xml6
-rw-r--r--docs/users_guide/glasgow_exts.xml20
3 files changed, 27 insertions, 1 deletions
diff --git a/docs/users_guide/7.10.1-notes.xml b/docs/users_guide/7.10.1-notes.xml
index c462a4dab4..b45721cd7b 100644
--- a/docs/users_guide/7.10.1-notes.xml
+++ b/docs/users_guide/7.10.1-notes.xml
@@ -31,7 +31,7 @@
<itemizedlist>
<listitem>
<para>
- TODO FIXME
+ Added support for <link linkend="binary-literals">binary integer literals</link>
</para>
</listitem>
</itemizedlist>
diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
index ad9c44c44b..1dd224a611 100644
--- a/docs/users_guide/flags.xml
+++ b/docs/users_guide/flags.xml
@@ -763,6 +763,12 @@
<entry><option>-XNoBangPatterns</option></entry>
</row>
<row>
+ <entry><option>-XBinaryLiterals</option></entry>
+ <entry>Enable support for <link linkend="binary-literals">binary literals</link>.</entry>
+ <entry>dynamic</entry>
+ <entry><option>-XNoBinaryLiterals</option></entry>
+ </row>
+ <row>
<entry><option>-XCApiFFI</option></entry>
<entry>Enable <link linkend="ffi-capi">the CAPI calling convention</link>.</entry>
<entry>dynamic</entry>
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index e959a1f2ab..e97d5798fe 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -480,6 +480,26 @@ Indeed, the bindings can even be recursive.
</para>
</sect2>
+ <sect2 id="binary-literals">
+ <title>Binary integer literals</title>
+ <para>
+ Haskell 2010 and Haskell 98 allows for integer literals to
+ be given in decimal, octal (prefixed by
+ <literal>0o</literal> or <literal>0O</literal>), or
+ hexadecimal notation (prefixed by <literal>0x</literal> or
+ <literal>0X</literal>).
+ </para>
+
+ <para>
+ The language extension <option>-XBinaryLiterals</option>
+ adds support for expressing integer literals in binary
+ notation with the prefix <literal>0b</literal> or
+ <literal>0B</literal>. For instance, the binary integer
+ literal <literal>0b11001001</literal> will be desugared into
+ <literal>fromInteger 201</literal> when
+ <option>-XBinaryLiterals</option> is enabled.
+ </para>
+ </sect2>
<!-- ====================== HIERARCHICAL MODULES ======================= -->