summaryrefslogtreecommitdiff
path: root/testsuite/tests/ado
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2017-10-26 11:23:23 +0100
committerSimon Marlow <marlowsd@gmail.com>2017-10-27 14:48:23 +0100
commit41f905596dc2560f29657753e4c69ce695161786 (patch)
tree071774ec3b99b5644f3b16f25e464f2da2558eef /testsuite/tests/ado
parent7d7d94fb4876dc7e58263abc9dd65921e09cddac (diff)
downloadhaskell-41f905596dc2560f29657753e4c69ce695161786.tar.gz
ApplicativeDo: handle BodyStmt (#12143)
Summary: It's simple to treat BodyStmt just like a BindStmt with a wildcard pattern, which is enough to fix #12143 without going all the way to using `<*` and `*>` (#10892). Test Plan: * new test cases in `ado004.hs` * validate Reviewers: niteria, simonpj, bgamari, austin, erikd Subscribers: rwbarton, thomie GHC Trac Issues: #12143 Differential Revision: https://phabricator.haskell.org/D4128
Diffstat (limited to 'testsuite/tests/ado')
-rw-r--r--testsuite/tests/ado/ado004.hs18
-rw-r--r--testsuite/tests/ado/ado004.stderr8
2 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/ado/ado004.hs b/testsuite/tests/ado/ado004.hs
index fa3c7231de..e7166c008e 100644
--- a/testsuite/tests/ado/ado004.hs
+++ b/testsuite/tests/ado/ado004.hs
@@ -16,6 +16,19 @@ test1a f = do
y <- f 4
return $ x + y
+-- When one of the statements is a BodyStmt
+test1b :: Applicative f => (Int -> f Int) -> f Int
+test1b f = do
+ x <- f 3
+ f 4
+ return x
+
+test1c :: Applicative f => (Int -> f Int) -> f Int
+test1c f = do
+ f 3
+ x <- f 4
+ return x
+
-- Test we can also infer the Applicative version of the type
test2 f = do
x <- f 3
@@ -32,6 +45,11 @@ test2c f = do
x <- f 3
return $ x + 1
+-- with a BodyStmt
+test2d f = do
+ f 3
+ return 4
+
-- Test for just one statement
test2b f = do
return (f 3)
diff --git a/testsuite/tests/ado/ado004.stderr b/testsuite/tests/ado/ado004.stderr
index 9b95e3bd3d..a3ef9e9158 100644
--- a/testsuite/tests/ado/ado004.stderr
+++ b/testsuite/tests/ado/ado004.stderr
@@ -3,6 +3,10 @@ TYPE SIGNATURES
forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int
test1a ::
forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int
+ test1b ::
+ forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int
+ test1c ::
+ forall (f :: * -> *). Applicative f => (Int -> f Int) -> f Int
test2 ::
forall (f :: * -> *) t b.
(Num b, Num t, Applicative f) =>
@@ -17,6 +21,10 @@ TYPE SIGNATURES
forall (f :: * -> *) t b.
(Num b, Num t, Functor f) =>
(t -> f b) -> f b
+ test2d ::
+ forall (f :: * -> *) t1 b t2.
+ (Num b, Num t1, Functor f) =>
+ (t1 -> f t2) -> f b
test3 ::
forall (m :: * -> *) t1 t2 a.
(Num t1, Monad m) =>