summaryrefslogtreecommitdiff
path: root/docs/users_guide/exts/lambda_case.rst
diff options
context:
space:
mode:
authorJakob Bruenker <jakob.bruenker@gmail.com>2022-03-21 00:14:25 +0100
committerJakob Bruenker <jakob.bruenker@gmail.com>2022-03-31 17:45:37 +0200
commita9c0c69b42657d39f26ab822241900ba0f308dc3 (patch)
treefd59a5e49146ee436e04137b313d8e4178c2bed0 /docs/users_guide/exts/lambda_case.rst
parentdda46e2da13268c239db3290720b014cef00c01d (diff)
downloadhaskell-wip/T20768.tar.gz
Implement \cases (Proposal 302)wip/T20768
This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768
Diffstat (limited to 'docs/users_guide/exts/lambda_case.rst')
-rw-r--r--docs/users_guide/exts/lambda_case.rst19
1 files changed, 16 insertions, 3 deletions
diff --git a/docs/users_guide/exts/lambda_case.rst b/docs/users_guide/exts/lambda_case.rst
index 74bc84e164..6872101698 100644
--- a/docs/users_guide/exts/lambda_case.rst
+++ b/docs/users_guide/exts/lambda_case.rst
@@ -18,7 +18,20 @@ which is equivalent to ::
\freshName -> case freshName of { p1 -> e1; ...; pN -> eN }
-Note that ``\case`` starts a layout, so you can write ::
+Since GHC 9.4.1, it also allow expressions with multiple scrutinees (see GHC
+proposal `#302 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0302-cases.rst>`_)
+of the form ::
+
+ \cases { p11 ... pM1 -> e1; ...; p1N ... pMN -> eN }
+
+which is equivalent to a function defined as
+
+ f p11 ... pM1 -> e1
+ ...
+ f p1N ... pMN -> eN
+
+
+Note that both ``\case`` and ``\cases`` start a layout, so you can write ::
\case
p1 -> e1
@@ -26,8 +39,8 @@ Note that ``\case`` starts a layout, so you can write ::
pN -> eN
Additionally, since GHC 9.0.1, combining :extension:`LambdaCase` with
-:extension:`Arrows` allows ``\case`` syntax to be used as a command in
-``proc`` notation: ::
+:extension:`Arrows` allows ``\case`` (and since GHC 9.4.1 ``\cases``)
+syntax to be used as a command in ``proc`` notation: ::
proc x -> (f -< x) `catchA` \case
p1 -> cmd1