summaryrefslogtreecommitdiff
path: root/testsuite
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-04-01 20:31:08 +0200
commit32070e6c2e1b4b7c32530a9566fe14543791f9a6 (patch)
treef0913ef2a69fd660542723ec07240167dbd37961 /testsuite
parentd85c7dcb7c457efc23b20ac8f4e4ae88bae5b050 (diff)
downloadhaskell-32070e6c2e1b4b7c32530a9566fe14543791f9a6.tar.gz
Implement \cases (Proposal 302)
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 'testsuite')
-rw-r--r--testsuite/tests/arrows/should_fail/T20768_arrow_fail.hs29
-rw-r--r--testsuite/tests/arrows/should_fail/T20768_arrow_fail.stderr66
-rw-r--r--testsuite/tests/arrows/should_fail/all.T1
-rw-r--r--testsuite/tests/arrows/should_run/ArrowLambdaCase.hs22
-rw-r--r--testsuite/tests/arrows/should_run/ArrowLambdaCase.stdout2
-rw-r--r--testsuite/tests/corelint/T21115b.stderr6
-rw-r--r--testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr2
-rw-r--r--testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr2
-rw-r--r--testsuite/tests/parser/should_fail/T16270.stderr17
-rw-r--r--testsuite/tests/perf/compiler/hard_hole_fits.hs3
-rw-r--r--testsuite/tests/perf/compiler/hard_hole_fits.stderr8
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr2
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr8
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr6
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr12
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr4
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr10
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr8
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr4
-rw-r--r--testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr12
-rw-r--r--testsuite/tests/printer/Ppr020.hs8
-rw-r--r--testsuite/tests/printer/PprArrowLambdaCase.hs8
-rw-r--r--testsuite/tests/rep-poly/RepPolyMatch.stderr2
-rw-r--r--testsuite/tests/typecheck/should_compile/hard_hole_fits.hs3
-rw-r--r--testsuite/tests/typecheck/should_compile/hard_hole_fits.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T20768_fail.hs12
-rw-r--r--testsuite/tests/typecheck/should_fail/T20768_fail.stderr31
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_run/T20768.hs24
-rw-r--r--testsuite/tests/typecheck/should_run/T20768.stdout4
-rwxr-xr-xtestsuite/tests/typecheck/should_run/all.T1
31 files changed, 263 insertions, 57 deletions
diff --git a/testsuite/tests/arrows/should_fail/T20768_arrow_fail.hs b/testsuite/tests/arrows/should_fail/T20768_arrow_fail.hs
new file mode 100644
index 0000000000..3b35efb366
--- /dev/null
+++ b/testsuite/tests/arrows/should_fail/T20768_arrow_fail.hs
@@ -0,0 +1,29 @@
+{-# Language LambdaCase, Arrows #-}
+
+import Control.Arrow
+
+main = return ()
+
+baz :: ArrowChoice p => p (Maybe Int) String
+baz = proc x ->
+ (| id (\cases
+ Just x | x > 100 -> returnA -< "big " ++ show x
+ 1 2 | otherwise -> returnA -< "small " ++ show x
+ -> returnA -< "none")
+ |) x
+
+foo :: Arrow p => p (Maybe Int) String
+foo = proc x ->
+ (| id (\cases
+ (Just x) | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none")
+ |) x
+
+bar :: ArrowChoice p => p (Maybe Int) String
+bar = proc x ->
+ (| id (\cases
+ (Just x) | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none")
+ |) (Just x)
diff --git a/testsuite/tests/arrows/should_fail/T20768_arrow_fail.stderr b/testsuite/tests/arrows/should_fail/T20768_arrow_fail.stderr
new file mode 100644
index 0000000000..b20fc2b03a
--- /dev/null
+++ b/testsuite/tests/arrows/should_fail/T20768_arrow_fail.stderr
@@ -0,0 +1,66 @@
+
+T20768_arrow_fail.hs:9:10:
+ /cases alternatives within arrow notation have different numbers of arguments
+ T20768_arrow_fail.hs:10:6-54
+ T20768_arrow_fail.hs:12:6-25
+ In the command: /cases
+ Just x | x > 100 -> returnA -< "big " ++ show x
+ 1 2 | otherwise -> returnA -< "small " ++ show x
+ -> returnA -< "none"
+ In the command: (| id
+ (/cases
+ Just x | x > 100 -> returnA -< "big " ++ show x
+ 1 2 | otherwise -> returnA -< "small " ++ show x
+ -> returnA -< "none") |)
+ In the command: (| id
+ (/cases
+ Just x | x > 100 -> returnA -< "big " ++ show x
+ 1 2 | otherwise -> returnA -< "small " ++ show x
+ -> returnA -< "none") |)
+ x
+
+T20768_arrow_fail.hs:17:9:
+ Could not deduce (ArrowChoice p) arising from an arrow command
+ from the context: Arrow p
+ bound by the type signature for:
+ foo :: forall (p :: * -> * -> *). Arrow p => p (Maybe Int) String
+ at T20768_arrow_fail.hs:15:1-38
+ Possible fix:
+ add (ArrowChoice p) to the context of
+ the type signature for:
+ foo :: forall (p :: * -> * -> *). Arrow p => p (Maybe Int) String
+ In the command: (| id
+ (/cases
+ (Just x)
+ | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none") |)
+ In the command: (| id
+ (/cases
+ (Just x)
+ | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none") |)
+ x
+ In the expression:
+ proc x -> (| id
+ (/cases
+ (Just x)
+ | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none") |)
+ x
+
+T20768_arrow_fail.hs:26:21:
+ Could not deduce (Num (Maybe Int)) arising from the literal ‘100’
+ from the context: ArrowChoice p
+ bound by the type signature for:
+ bar :: forall (p :: * -> * -> *).
+ ArrowChoice p =>
+ p (Maybe Int) String
+ at T20768_arrow_fail.hs:23:1-44
+ In the second argument of ‘(>)’, namely ‘100’
+ In the expression: x > 100
+ In a stmt of a pattern guard for
+ a /cases alternative within arrow notation:
+ x > 100
diff --git a/testsuite/tests/arrows/should_fail/all.T b/testsuite/tests/arrows/should_fail/all.T
index ba8e07440f..382f00aac0 100644
--- a/testsuite/tests/arrows/should_fail/all.T
+++ b/testsuite/tests/arrows/should_fail/all.T
@@ -3,3 +3,4 @@ test('arrowfail003', normal, compile_fail, [''])
test('arrowfail004', normal, compile_fail, [''])
test('T2111', normal, compile_fail, [''])
test('T5380', normal, compile_fail, [''])
+test('T20768_arrow_fail', normal, compile_fail, [''])
diff --git a/testsuite/tests/arrows/should_run/ArrowLambdaCase.hs b/testsuite/tests/arrows/should_run/ArrowLambdaCase.hs
index c678339890..1c671e5c8b 100644
--- a/testsuite/tests/arrows/should_run/ArrowLambdaCase.hs
+++ b/testsuite/tests/arrows/should_run/ArrowLambdaCase.hs
@@ -2,12 +2,17 @@
module Main (main) where
import Control.Arrow
+import Data.Function
main :: IO ()
main = do
putStrLn $ foo (Just 42)
putStrLn $ foo (Just 500)
putStrLn $ foo Nothing
+ putStrLn $ map ($ Just 42) [foo, bar] & \cases
+ [foo', bar'] | foo' == bar' -> "success!"
+ | otherwise -> error "failed"
+ putStrLn $ baz 12 1 (Just 42)
foo :: ArrowChoice p => p (Maybe Int) String
foo = proc x ->
@@ -16,3 +21,20 @@ foo = proc x ->
| otherwise -> returnA -< "small " ++ show x
Nothing -> returnA -< "none")
|) x
+
+bar :: ArrowChoice p => p (Maybe Int) String
+bar = proc x ->
+ (| id (\cases
+ (Just x) | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing -> returnA -< "none")
+ |) x
+
+baz :: ArrowChoice p => Int -> Int -> p (Maybe Int) String
+baz a b = proc x ->
+ (| id (\cases
+ (Just x) 12 20 | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ Nothing _ _ -> returnA -< "none"
+ _ 12 1 -> returnA -< "less than none")
+ |) x a b
diff --git a/testsuite/tests/arrows/should_run/ArrowLambdaCase.stdout b/testsuite/tests/arrows/should_run/ArrowLambdaCase.stdout
index 09e50cf6d7..d61b497aee 100644
--- a/testsuite/tests/arrows/should_run/ArrowLambdaCase.stdout
+++ b/testsuite/tests/arrows/should_run/ArrowLambdaCase.stdout
@@ -1,3 +1,5 @@
small 42
big 500
none
+success!
+less than none
diff --git a/testsuite/tests/corelint/T21115b.stderr b/testsuite/tests/corelint/T21115b.stderr
index 8833208b19..eaa70cc22f 100644
--- a/testsuite/tests/corelint/T21115b.stderr
+++ b/testsuite/tests/corelint/T21115b.stderr
@@ -19,7 +19,7 @@ foo
let {
fail
= \ ds ->
- case patError "T21115b.hs:(10,4)-(15,4)|case"# of wild { } } in
+ case patError "T21115b.hs:(10,4)-(15,4)|\\case"# of wild { } } in
let { fail = \ ds -> 5# } in
case ds of ds {
__DEFAULT -> fail void#;
@@ -31,7 +31,5 @@ end Rec }
*** End of Offense ***
-<no location info>: error:
+<no location info>: error:
Compilation had errors
-
-
diff --git a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr
index 93a3c99d49..f6d7dca47a 100644
--- a/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr
+++ b/testsuite/tests/parser/should_fail/NoBlockArgumentsFail3.stderr
@@ -1,6 +1,6 @@
NoBlockArgumentsFail3.hs:7:22: error:
- Unexpected lambda-case expression in function application:
+ Unexpected \case expression in function application:
\case Just 3 -> print x
Suggested fixes:
Use parentheses.
diff --git a/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr b/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr
index df4cb72d0f..ef1d3d6b83 100644
--- a/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr
+++ b/testsuite/tests/parser/should_fail/ParserNoLambdaCase.stderr
@@ -1,3 +1,3 @@
ParserNoLambdaCase.hs:3:6:
- Illegal lambda-case
+ Illegal \case
Suggested fix: Perhaps you intended to use LambdaCase
diff --git a/testsuite/tests/parser/should_fail/T16270.stderr b/testsuite/tests/parser/should_fail/T16270.stderr
index e928638539..b4460b9cce 100644
--- a/testsuite/tests/parser/should_fail/T16270.stderr
+++ b/testsuite/tests/parser/should_fail/T16270.stderr
@@ -26,18 +26,17 @@ T16270.hs:14:8: error:
Perhaps you intended to use BlockArguments
T16270.hs:18:22: error:
- Illegal record syntax: {fst :: a,
- snd :: b}
+ Illegal record syntax: {fst :: a, snd :: b}
Suggested fix: Perhaps you intended to use TraditionalRecordSyntax
T16270.hs:19:5: error:
- Illegal record syntax: p {fst = 1,
- snd = True}
+ Illegal record syntax: p {fst = 1, snd = True}
Suggested fix: Perhaps you intended to use TraditionalRecordSyntax
T16270.hs:21:6: error:
Illegal symbol ‘forall’ in type
- Suggested fix: Perhaps you intended to use RankNTypes
+ Suggested fix:
+ Perhaps you intended to use RankNTypes
or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
T16270.hs:22:8: error:
@@ -47,7 +46,8 @@ T16270.hs:22:8: error:
T16270.hs:24:10: error:
Illegal keyword 'where' in data declaration
- Suggested fix: Perhaps you intended to use GADTs
+ Suggested fix:
+ Perhaps you intended to use GADTs
or a similar language extension to enable syntax: data T where
T16270.hs:26:12: error:
@@ -64,7 +64,7 @@ T16270.hs:30:9: error:
Suggested fix: Perhaps you intended to use MultiWayIf
T16270.hs:33:6:
- Illegal lambda-case
+ Illegal \case
Suggested fix: Perhaps you intended to use LambdaCase
T16270.hs:36:5: error:
@@ -74,8 +74,7 @@ T16270.hs:36:5: error:
T16270.hs:38:5: error:
primitive string literal must contain only characters <= '\xFF'
-T16270.hs:40:7: error:
- A lambda requires at least one parameter
+T16270.hs:40:7: error: A lambda requires at least one parameter
T16270.hs:46:1: error:
parse error (possibly incorrect indentation or mismatched brackets)
diff --git a/testsuite/tests/perf/compiler/hard_hole_fits.hs b/testsuite/tests/perf/compiler/hard_hole_fits.hs
index c59fe1b0dd..250c96e5ff 100644
--- a/testsuite/tests/perf/compiler/hard_hole_fits.hs
+++ b/testsuite/tests/perf/compiler/hard_hole_fits.hs
@@ -18,7 +18,7 @@ testMe (HsIPVar xv hin) = _
testMe (HsOverLit xole hol) = _
testMe (HsLit xle hl) = _
testMe (HsLam xl mg) = _
-testMe (HsLamCase xlc mg) = _
+testMe (HsLamCase xlc lc_variant mg) = _
testMe (HsApp xa gl gl') = _
testMe (HsAppType xate gl hwcb) = _
testMe (OpApp xoa gl gl' gl2) = _
@@ -44,4 +44,3 @@ testMe (HsSpliceE xse hs) = _
testMe (HsProc xp pat gl) = _
testMe (HsStatic xs gl) = _
testMe (XExpr xe) = _
-
diff --git a/testsuite/tests/perf/compiler/hard_hole_fits.stderr b/testsuite/tests/perf/compiler/hard_hole_fits.stderr
index 4b59171506..55c267076d 100644
--- a/testsuite/tests/perf/compiler/hard_hole_fits.stderr
+++ b/testsuite/tests/perf/compiler/hard_hole_fits.stderr
@@ -132,12 +132,14 @@ hard_hole_fits.hs:20:24: warning: [-Wtyped-holes (in -Wdefault)]
(imported from ‘Prelude’ at hard_hole_fits.hs:8:8-20
(and originally defined in ‘GHC.Enum’))
-hard_hole_fits.hs:21:29: warning: [-Wtyped-holes (in -Wdefault)]
+hard_hole_fits.hs:21:40: warning: [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int
- • In an equation for ‘testMe’: testMe (HsLamCase xlc mg) = _
+ • In an equation for ‘testMe’:
+ testMe (HsLamCase xlc lc_variant mg) = _
• Relevant bindings include
mg :: MatchGroup GhcPs (LHsExpr GhcPs)
- (bound at hard_hole_fits.hs:21:23)
+ (bound at hard_hole_fits.hs:21:34)
+ lc_variant :: LamCaseVariant (bound at hard_hole_fits.hs:21:23)
xlc :: Language.Haskell.Syntax.Extension.XLamCase GhcPs
(bound at hard_hole_fits.hs:21:19)
testMe :: HsExpr GhcPs -> Int (bound at hard_hole_fits.hs:14:1)
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr
index cd00f26f8b..2ec7564492 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr
@@ -1,7 +1,7 @@
EmptyCase001.hs:9:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘Int’ not matched: _
+ In a \case alternative: Patterns of type ‘Int’ not matched: _
EmptyCase001.hs:14:8: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr
index 691c62b79d..aac509d1f1 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr
@@ -1,25 +1,25 @@
EmptyCase002.hs:16:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘T’ not matched: MkT _
+ In a \case alternative: Patterns of type ‘T’ not matched: MkT _
EmptyCase002.hs:43:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘T1 B’ not matched:
MkT1 B1
MkT1 B2
EmptyCase002.hs:47:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘T1 (E Int)’ not matched:
MkT1 False
MkT1 True
EmptyCase002.hs:51:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘T1
(T2 (T1 (D (E Int) (E (E Int)))))’ not matched:
MkT1 (MkT2 (MkT1 D2))
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr
index e9f6e27cd3..11c2addfa3 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr
@@ -1,12 +1,12 @@
EmptyCase003.hs:15:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘A a’ not matched: _
+ In a \case alternative: Patterns of type ‘A a’ not matched: _
EmptyCase003.hs:32:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘C a’ not matched: _
+ In a \case alternative: Patterns of type ‘C a’ not matched: _
EmptyCase003.hs:37:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘C Int’ not matched: _
+ In a \case alternative: Patterns of type ‘C Int’ not matched: _
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr
index 7dc717c934..9491cc06df 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr
@@ -1,11 +1,11 @@
EmptyCase004.hs:15:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘A Bool’ not matched: A2
+ In a \case alternative: Patterns of type ‘A Bool’ not matched: A2
EmptyCase004.hs:19:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘A a’ not matched:
A1
A2
@@ -16,22 +16,22 @@ EmptyCase004.hs:31:8: warning: [-Wincomplete-patterns (in -Wextra)]
EmptyCase004.hs:35:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘B a b’ not matched:
B1 _
B2
EmptyCase004.hs:47:6: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘A a’ not matched:
A1
A2
EmptyCase004.hs:50:9: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘B a b’ not matched: B2
+ In a \case alternative: Patterns of type ‘B a b’ not matched: B2
EmptyCase004.hs:51:9: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative: Patterns of type ‘B a b’ not matched: B1 _
+ In a \case alternative: Patterns of type ‘B a b’ not matched: B1 _
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr
index 9062f1c40a..7c75c73115 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr
@@ -1,12 +1,12 @@
EmptyCase006.hs:18:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo1 Int’ not matched: Foo1 MkGA1
EmptyCase006.hs:26:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo1 a’ not matched:
Foo1 MkGA1
Foo1 (MkGA2 _)
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr
index 7adef0854a..14693dcdcb 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr
@@ -1,22 +1,22 @@
EmptyCase007.hs:21:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo2 a’ not matched: Foo2 _
EmptyCase007.hs:25:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo2 (a, a)’ not matched: Foo2 _
EmptyCase007.hs:33:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo2 Int’ not matched: Foo2 (_, _)
EmptyCase007.hs:37:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo2 Char’ not matched: Foo2 _
EmptyCase007.hs:44:17: warning: [-Wincomplete-patterns (in -Wextra)]
@@ -25,7 +25,7 @@ EmptyCase007.hs:44:17: warning: [-Wincomplete-patterns (in -Wextra)]
EmptyCase007.hs:48:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo2 [Int]’ not matched:
Foo2 []
Foo2 (_:_)
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr
index c826a05569..66e70e0a7e 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr
@@ -1,22 +1,22 @@
EmptyCase008.hs:17:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo3 Int’ not matched:
Foo3 (MkDA1 _)
Foo3 MkDA2
EmptyCase008.hs:21:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo3 a’ not matched: Foo3 _
EmptyCase008.hs:40:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo4 Int ()’ not matched: Foo4 MkDB1
EmptyCase008.hs:48:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Foo4 a b’ not matched: Foo4 _
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr
index ca6ca03e9f..622493b446 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr
@@ -5,10 +5,10 @@ EmptyCase009.hs:21:9: warning: [-Wincomplete-patterns (in -Wextra)]
EmptyCase009.hs:33:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Bar (DB ())’ not matched: Bar MkDB2_u
EmptyCase009.hs:42:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Bar GB’ not matched: Bar MkGB3
diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr
index 8202c65a22..0672f17f69 100644
--- a/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr
+++ b/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr
@@ -1,19 +1,19 @@
EmptyCase010.hs:24:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz GC a’ not matched:
Baz MkGC1
Baz (MkGC2 _)
EmptyCase010.hs:28:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz GC 'T1’ not matched: Baz MkGC1
EmptyCase010.hs:37:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz GD Maybe’ not matched:
Baz MkGD1
Baz MkGD3
@@ -25,7 +25,7 @@ EmptyCase010.hs:41:9: warning: [-Wincomplete-patterns (in -Wextra)]
EmptyCase010.hs:45:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz GD f’ not matched:
Baz MkGD1
Baz MkGD2
@@ -33,12 +33,12 @@ EmptyCase010.hs:45:7: warning: [-Wincomplete-patterns (in -Wextra)]
EmptyCase010.hs:57:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz (DC ()) a’ not matched: Baz _
EmptyCase010.hs:69:7: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In a case alternative:
+ In a \case alternative:
Patterns of type ‘Baz (DC Bool) [Int]’ not matched: Baz MkDC2
EmptyCase010.hs:73:9: warning: [-Wincomplete-patterns (in -Wextra)]
diff --git a/testsuite/tests/printer/Ppr020.hs b/testsuite/tests/printer/Ppr020.hs
index f567f726a1..d930a73ac3 100644
--- a/testsuite/tests/printer/Ppr020.hs
+++ b/testsuite/tests/printer/Ppr020.hs
@@ -4,6 +4,14 @@ foo = f >>= \case
Just h -> loadTestDB (h ++ "/.testdb")
Nothing -> fmap S.Right initTestDB
+foo = f >>= \cases
+ x (Just h) -> loadTestDB (h ++ "/.testdb")
+ _ Nothing -> fmap S.Right initTestDB
+
+foo = f >>= \cases
+ | a -> loadTestDB (h ++ "/.testdb")
+ | b -> fmap S.Right initTestDB
+
{-| Is the alarm set - i.e. will it go off at some point in the future even if
`setAlarm` is not called? -}
isAlarmSetSTM :: AlarmClock -> STM Bool
diff --git a/testsuite/tests/printer/PprArrowLambdaCase.hs b/testsuite/tests/printer/PprArrowLambdaCase.hs
index c678339890..9760d1372e 100644
--- a/testsuite/tests/printer/PprArrowLambdaCase.hs
+++ b/testsuite/tests/printer/PprArrowLambdaCase.hs
@@ -16,3 +16,11 @@ foo = proc x ->
| otherwise -> returnA -< "small " ++ show x
Nothing -> returnA -< "none")
|) x
+
+foo :: ArrowChoice p => p (Maybe Int) String
+foo = proc x ->
+ (| id (\cases
+ y (Just x) | x > 100 -> returnA -< "big " ++ show x
+ | otherwise -> returnA -< "small " ++ show x
+ _ Nothing -> returnA -< "none")
+ |) 1 x
diff --git a/testsuite/tests/rep-poly/RepPolyMatch.stderr b/testsuite/tests/rep-poly/RepPolyMatch.stderr
index 420c38efe2..d845426032 100644
--- a/testsuite/tests/rep-poly/RepPolyMatch.stderr
+++ b/testsuite/tests/rep-poly/RepPolyMatch.stderr
@@ -1,6 +1,6 @@
RepPolyMatch.hs:11:9: error:
- • The binder of the lambda-case expression
+ • The binder of the \case expression
does not have a fixed runtime representation.
Its type is:
a :: TYPE rep
diff --git a/testsuite/tests/typecheck/should_compile/hard_hole_fits.hs b/testsuite/tests/typecheck/should_compile/hard_hole_fits.hs
index a1cbec4b59..b74aeb4eae 100644
--- a/testsuite/tests/typecheck/should_compile/hard_hole_fits.hs
+++ b/testsuite/tests/typecheck/should_compile/hard_hole_fits.hs
@@ -18,7 +18,7 @@ testMe (HsIPVar xv hin) = _
testMe (HsOverLit xole hol) = _
testMe (HsLit xle hl) = _
testMe (HsLam xl mg) = _
-testMe (HsLamCase xlc mg) = _
+testMe (HsLamCase xlc lc_variant mg) = _
testMe (HsApp xa gl gl') = _
testMe (HsAppType xate gl hwcb) = _
testMe (OpApp xoa gl gl' gl2) = _
@@ -45,4 +45,3 @@ testMe (HsSpliceE xse hs) = _
testMe (HsProc xp pat gl) = _
testMe (HsStatic xs gl) = _
testMe (XExpr xe) = _
-
diff --git a/testsuite/tests/typecheck/should_compile/hard_hole_fits.stderr b/testsuite/tests/typecheck/should_compile/hard_hole_fits.stderr
index 78a3584f1c..672cca7440 100644
--- a/testsuite/tests/typecheck/should_compile/hard_hole_fits.stderr
+++ b/testsuite/tests/typecheck/should_compile/hard_hole_fits.stderr
@@ -134,7 +134,7 @@ hard_hole_fits.hs:20:24: warning: [-Wtyped-holes (in -Wdefault)]
hard_hole_fits.hs:21:29: warning: [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int
- • In an equation for ‘testMe’: testMe (HsLamCase xlc mg) = _
+ • In an equation for ‘testMe’: testMe (HsLamCase xlc lc_variant mg) = _
• Relevant bindings include
mg :: MatchGroup GhcPs (LHsExpr GhcPs)
(bound at hard_hole_fits.hs:21:23)
diff --git a/testsuite/tests/typecheck/should_fail/T20768_fail.hs b/testsuite/tests/typecheck/should_fail/T20768_fail.hs
new file mode 100644
index 0000000000..c2531f2075
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T20768_fail.hs
@@ -0,0 +1,12 @@
+{-# language LambdaCase #-}
+
+module Main where
+
+import Data.Function
+
+bar = \cases | 'c' -> "foo"
+
+main = (\cases 1 2 -> return ()) "foo"
+
+foo = 1 & \cases 1 2 -> return ()
+ 1 -> return ()
diff --git a/testsuite/tests/typecheck/should_fail/T20768_fail.stderr b/testsuite/tests/typecheck/should_fail/T20768_fail.stderr
new file mode 100644
index 0000000000..86bb3b5216
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T20768_fail.stderr
@@ -0,0 +1,31 @@
+
+T20768_fail.hs:7:16:
+ Couldn't match expected type ‘Bool’ with actual type ‘Char’
+ In the expression: 'c'
+ In a stmt of a pattern guard for
+ a /cases alternative:
+ 'c'
+ In a /cases alternative: | 'c' -> "foo"
+
+T20768_fail.hs:9:1:
+ Couldn't match expected type: IO t0
+ with actual type: a0 -> m0 ()
+ When checking the type of the IO action ‘main’
+
+T20768_fail.hs:11:11:
+ /cases alternatives have different numbers of arguments
+ T20768_fail.hs:11:18-33
+ T20768_fail.hs:12:18-31
+ In the second argument of ‘(&)’, namely
+ ‘/cases
+ 1 2 -> return ()
+ 1 -> return ()’
+ In the expression:
+ 1 & /cases
+ 1 2 -> return ()
+ 1 -> return ()
+ In an equation for ‘foo’:
+ foo
+ = 1 & /cases
+ 1 2 -> return ()
+ 1 -> return ()
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index a8a4e4d3b5..939d9b156e 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -651,3 +651,4 @@ test('T18406', normal, compile_fail, [''])
test('AmbigFDs', normal, compile_fail, [''])
test('T20064', normal, compile_fail, [''])
test('T21130', normal, compile_fail, [''])
+test('T20768_fail', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_run/T20768.hs b/testsuite/tests/typecheck/should_run/T20768.hs
new file mode 100644
index 0000000000..258604782b
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T20768.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE BlockArguments #-}
+{-# LANGUAGE UnboxedTuples #-}
+{-# LANGUAGE MagicHash #-}
+
+module Main where
+
+import Data.Function
+import GHC.Exts
+
+main :: IO ()
+main = do
+ putStrLn \cases | 1 < 1 -> "foo"
+ | otherwise -> "bar"
+ print $ (\cases 1 _ -> error "no"; x y -> x + y) 4 5
+ (Just 4) & ("23" & \cases
+ "23" Nothing -> print "failed"
+ s (Just x) -> putStrLn $ s ++ show x)
+
+ unboxed 1 2# (# 3, "4"# #)
+
+unboxed :: Int -> Int# -> (# Int, Addr# #) -> IO ()
+unboxed = \cases 1 1# (# 3 , s #) -> print ()
+ (I# x) y (# (I# z), s #) -> putStrLn $ show (I# (x +# y +# z)) ++ unpackCString# s
diff --git a/testsuite/tests/typecheck/should_run/T20768.stdout b/testsuite/tests/typecheck/should_run/T20768.stdout
new file mode 100644
index 0000000000..93d261ee36
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T20768.stdout
@@ -0,0 +1,4 @@
+bar
+9
+234
+64
diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T
index a465999b58..b4e04a118c 100755
--- a/testsuite/tests/typecheck/should_run/all.T
+++ b/testsuite/tests/typecheck/should_run/all.T
@@ -162,3 +162,4 @@ test('T19397M2', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo'])
test('T19397M3', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo'])
test('T19397M4', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo'])
test('T19667', normal, compile_and_run, ['-fhpc'])
+test('T20768', normal, compile_and_run, [''])