[Git][ghc/ghc][master] Improve docs for NondecreasingIndentation
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Fri Jul 12 15:41:14 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
46ec0a8e by Torsten Schmits at 2024-07-09T13:37:02+02:00
Improve docs for NondecreasingIndentation
The text stated that this affects indentation of layouts nested in do
expressions, while it actually affects that of do layouts nested in any
other.
- - - - -
1 changed file:
- docs/users_guide/bugs.rst
Changes:
=====================================
docs/users_guide/bugs.rst
=====================================
@@ -129,14 +129,21 @@ Context-free syntax
expressions. Specifically, the restriction that "a nested context
must be indented further to the right than the enclosing context" is
relaxed to allow the nested context to be at the same level as the
- enclosing context, if the enclosing context is a ``do`` expression.
+ enclosing context, if the nested context is a ``do`` expression.
- For example, the following code is accepted by GHC: ::
+ For example, the following code, in which a ``do`` context is nested
+ within a case context, and the statement `feed animal` is indented by
+ the same amount as the case alt, is accepted by GHC: ::
- main = do args <- getArgs
- if null args then return [] else do
- ps <- mapM process args
- mapM print ps
+ main = case animal of
+ Wombat -> do
+ feed animal
+
+ But this code, with the inverse nesting, is not: ::
+
+ main = do
+ case animal of
+ Wombat -> feed animal
This behaviour is controlled by the :extension:`NondecreasingIndentation`
extension.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46ec0a8e11dea77254843ef8017dd19402374c75
--
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46ec0a8e11dea77254843ef8017dd19402374c75
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240712/4d66be25/attachment-0001.html>
More information about the ghc-commits
mailing list