summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pilgrem <mpilgrem@users.noreply.github.com>2022-10-23 17:52:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-09 09:42:56 -0500
commit1023b432d0befd9675dcfcfb44c548b06b2fae8c (patch)
treebc2af9ba5ffde7b80d16e52d6fb09ecfe40b25bb
parented239a24c71671c15ea59dae8073e4516558e47b (diff)
downloadhaskell-1023b432d0befd9675dcfcfb44c548b06b2fae8c.tar.gz
Fix #22300 Document GHC's extensions to valid whitespace
-rw-r--r--docs/users_guide/exts/misc.rst1
-rw-r--r--docs/users_guide/exts/whitespace.rst29
2 files changed, 30 insertions, 0 deletions
diff --git a/docs/users_guide/exts/misc.rst b/docs/users_guide/exts/misc.rst
index 7e51ffe80a..b5d7f78a86 100644
--- a/docs/users_guide/exts/misc.rst
+++ b/docs/users_guide/exts/misc.rst
@@ -9,3 +9,4 @@ Miscellaneous
generics
assert
callstack
+ whitespace
diff --git a/docs/users_guide/exts/whitespace.rst b/docs/users_guide/exts/whitespace.rst
new file mode 100644
index 0000000000..6defc2b4e0
--- /dev/null
+++ b/docs/users_guide/exts/whitespace.rst
@@ -0,0 +1,29 @@
+.. _whitespace:
+
+Whitespace
+==========
+
+.. index::
+ single: Whitespace
+
+As in the Haskell Language Report, Haskell comments are valid whitespace. In
+addition, lines (which must end with a line feed character) that begin as
+follows are valid whitespace in source code, except immediately after a
+``where``, ``let``, ``do`` or ``of`` keyword:
+
+- ``#!``. This accommodates 'shebang' interpreter directives in scripts on
+ Unix-like operating systems.
+
+- ``<space>#!``, where ``<space>`` is an initial space character before the
+ 'shebang'.
+
+- ``#pragma``. This accommodates the use of a directive that passes additional
+ information to a compiler.
+
+- ``#line <line> "<file>"``, where ``<line>`` is a positive integer and
+ ``<file>`` can comprise zero or more characters. This accommodates a compiler
+ directive that resets the numbering of lines of source code, and the
+ identification of the source code file name, in compiler messages.
+
+- ``#<line> "<file>"``, where ``<line>`` is a positive integer and ``<file>``
+ can comprise zero or more characters.