summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-10-28 09:41:27 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2015-10-28 09:46:22 +0000
commit04b0a73a2a418e1ca9c282ab3f2b4fe216911fdd (patch)
tree9914155e4873cd7a1b3c3dcee8fe12119b2ddbf2 /testsuite
parent9fc2d777f53110040f48ab27643a16888fa377f5 (diff)
downloadhaskell-04b0a73a2a418e1ca9c282ab3f2b4fe216911fdd.tar.gz
Pattern synonyms: swap provided/required
This patch swaps the order of provided and required constraints in a pattern signature, so it now goes pattern P :: req => prov => t1 -> ... tn -> res_ty See the long discussion in Trac #10928. I think I have found all the places, but I could have missed something particularly in comments. There is a Haddock changes; so a submodule update.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghci/scripts/T8776.stdout3
-rw-r--r--testsuite/tests/patsyn/should_compile/T10997_1a.hs2
-rw-r--r--testsuite/tests/patsyn/should_compile/T10997a.hs2
-rw-r--r--testsuite/tests/patsyn/should_compile/T8584-2.hs2
-rw-r--r--testsuite/tests/patsyn/should_fail/T11010.hs18
-rw-r--r--testsuite/tests/patsyn/should_fail/T11010.stderr8
-rw-r--r--testsuite/tests/patsyn/should_fail/all.T1
7 files changed, 32 insertions, 4 deletions
diff --git a/testsuite/tests/ghci/scripts/T8776.stdout b/testsuite/tests/ghci/scripts/T8776.stdout
index 7f8d57e7ee..937a270963 100644
--- a/testsuite/tests/ghci/scripts/T8776.stdout
+++ b/testsuite/tests/ghci/scripts/T8776.stdout
@@ -1 +1,2 @@
-pattern P :: (Num t, Eq t1) => A t t1 -- Defined at T8776.hs:6:1
+pattern P :: () => (Num t, Eq t1) => A t t1
+ -- Defined at T8776.hs:6:1
diff --git a/testsuite/tests/patsyn/should_compile/T10997_1a.hs b/testsuite/tests/patsyn/should_compile/T10997_1a.hs
index af98f495f7..f6a292aa54 100644
--- a/testsuite/tests/patsyn/should_compile/T10997_1a.hs
+++ b/testsuite/tests/patsyn/should_compile/T10997_1a.hs
@@ -11,7 +11,7 @@ extractJust :: Maybe a -> (Bool, a)
extractJust (Just a) = (True, a)
extractJust _ = (False, undefined)
-pattern Just' :: () => (Showable a) => a -> (Maybe a)
+pattern Just' :: Showable a => a -> (Maybe a)
pattern Just' a <- (extractJust -> (True, a)) where
Just' a = Just a
diff --git a/testsuite/tests/patsyn/should_compile/T10997a.hs b/testsuite/tests/patsyn/should_compile/T10997a.hs
index bed19f74e9..ec3c54238d 100644
--- a/testsuite/tests/patsyn/should_compile/T10997a.hs
+++ b/testsuite/tests/patsyn/should_compile/T10997a.hs
@@ -5,7 +5,7 @@ module T10997a where
data Exp ty where
LitB :: Bool -> Exp Bool
-pattern Tru :: b ~ Bool => Exp b
+pattern Tru :: () => b ~ Bool => Exp b
pattern Tru = LitB True
diff --git a/testsuite/tests/patsyn/should_compile/T8584-2.hs b/testsuite/tests/patsyn/should_compile/T8584-2.hs
index 24147a258d..379a8c872e 100644
--- a/testsuite/tests/patsyn/should_compile/T8584-2.hs
+++ b/testsuite/tests/patsyn/should_compile/T8584-2.hs
@@ -3,7 +3,7 @@
module ShouldCompile where
-pattern Single :: () => (Show a) => a -> [a]
+pattern Single :: Show a => a -> [a]
pattern Single x = [x]
f :: (Show a) => [a] -> a
diff --git a/testsuite/tests/patsyn/should_fail/T11010.hs b/testsuite/tests/patsyn/should_fail/T11010.hs
new file mode 100644
index 0000000000..c0bdb6e0d4
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/T11010.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE PatternSynonyms, ExistentialQuantification, GADTSyntax #-}
+
+module T11010 where
+
+data Expr a where
+ Fun :: String -> (a -> b) -> (Expr a -> Expr b)
+
+pattern IntFun :: (a ~ Int) => String -> (a -> b) -> (Expr a -> Expr b)
+pattern IntFun str f x = Fun str f x
+
+-- Alternative syntax for pattern synonyms:
+-- pattern
+-- Suc :: () => (a ~ Int) => Expr a -> Expr Int
+-- Suc n <- IntFun _ _ n where
+-- Suc n = IntFun "suc" (+ 1) n
+pattern Suc :: (a ~ Int) => Expr a -> Expr Int
+pattern Suc n <- IntFun _ _ n where
+ Suc n = IntFun "suc" (+ 1) n
diff --git a/testsuite/tests/patsyn/should_fail/T11010.stderr b/testsuite/tests/patsyn/should_fail/T11010.stderr
new file mode 100644
index 0000000000..5f62b1357e
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/T11010.stderr
@@ -0,0 +1,8 @@
+
+T11010.hs:8:1: error:
+ The 'required' context ‘a ~ Int’
+ mentions existential type variable ‘a’
+
+T11010.hs:16:1: error:
+ The 'required' context ‘a ~ Int’
+ mentions existential type variable ‘a’
diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T
index de5d6db3b4..846d2d37d9 100644
--- a/testsuite/tests/patsyn/should_fail/all.T
+++ b/testsuite/tests/patsyn/should_fail/all.T
@@ -8,3 +8,4 @@ test('T9705-1', normal, compile_fail, [''])
test('T9705-2', normal, compile_fail, [''])
test('unboxed-bind', normal, compile_fail, [''])
test('unboxed-wrapper-naked', normal, compile_fail, [''])
+test('T11010', normal, compile_fail, ['']) \ No newline at end of file