summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-05-11 23:19:14 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2015-05-18 13:44:15 +0100
commitffc21506894c7887d3620423aaf86bc6113a1071 (patch)
treec36353b98b3e5eeb9a257b39d95e56f441aa36da /testsuite/tests/typecheck/should_fail
parent76024fdbad0f6daedd8757b974eace3314bd4eec (diff)
downloadhaskell-ffc21506894c7887d3620423aaf86bc6113a1071.tar.gz
Refactor tuple constraints
Make tuple constraints be handled by a perfectly ordinary type class, with the component constraints being the superclasses: class (c1, c2) => (c2, c2) This change was provoked by #10359 inability to re-use a given tuple constraint as a whole #9858 confusion between term tuples and constraint tuples but it's generally a very nice simplification. We get rid of - In Type, the TuplePred constructor of PredTree, and all the code that dealt with TuplePreds - In TcEvidence, the constructors EvTupleMk, EvTupleSel See Note [How tuples work] in TysWiredIn. Of course, nothing is ever entirely simple. This one proved quite fiddly. - I did quite a bit of renaming, which makes this patch touch a lot of modules. In partiuclar tupleCon -> tupleDataCon. - I made constraint tuples known-key rather than wired-in. This is different to boxed/unboxed tuples, but it proved awkward to have all the superclass selectors wired-in. Easier just to use the standard mechanims. - While I was fiddling with known-key names, I split the TH Name definitions out of DsMeta into a new module THNames. That meant that the known-key names can all be gathered in PrelInfo, without causing module loops. - I found that the parser was parsing an import item like T( .. ) as a *data constructor* T, and then using setRdrNameSpace to fix it. Stupid! So I changed the parser to parse a *type constructor* T, which means less use of setRdrNameSpace. I also improved setRdrNameSpace to behave better on Exact Names. Largely on priciple; I don't think it matters a lot. - When compiling a data type declaration for a wired-in thing like tuples (,), or lists, we don't really need to look at the declaration. We have the wired-in thing! And not doing so avoids having to line up the uniques for data constructor workers etc. See Note [Declarations for wired-in things] - I found that FunDeps.oclose wasn't taking superclasses into account; easily fixed. - Some error message refactoring for invalid constraints in TcValidity - Haddock needs to absorb the change too; so there is a submodule update
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
-rw-r--r--testsuite/tests/typecheck/should_fail/T9858a.stderr28
-rw-r--r--testsuite/tests/typecheck/should_fail/fd-loop.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail108.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail154.stderr12
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail157.stderr24
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail213.stderr14
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail214.stderr12
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail220.hsig1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail220.stderr26
9 files changed, 67 insertions, 78 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T9858a.stderr b/testsuite/tests/typecheck/should_fail/T9858a.stderr
index 2f815b1824..61c62eaeec 100644
--- a/testsuite/tests/typecheck/should_fail/T9858a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T9858a.stderr
@@ -1,14 +1,14 @@
-
-T9858a.hs:28:18: error:
- No instance for (Typeable
- (((() :: Constraint), (() :: Constraint)) => ()))
- (maybe you haven't applied a function to enough arguments?)
- arising from a use of ‘cast’
- In the expression: cast e
- In the expression: case cast e of { Just e' -> ecast e' }
- In an equation for ‘supercast’:
- supercast
- = case cast e of { Just e' -> ecast e' }
- where
- e = Refl
- e :: E PX PX
+
+T9858a.hs:28:18: error:
+ No instance for (Typeable
+ ((() :: Constraint, () :: Constraint) => ()))
+ (maybe you haven't applied a function to enough arguments?)
+ arising from a use of ‘cast’
+ In the expression: cast e
+ In the expression: case cast e of { Just e' -> ecast e' }
+ In an equation for ‘supercast’:
+ supercast
+ = case cast e of { Just e' -> ecast e' }
+ where
+ e = Refl
+ e :: E PX PX
diff --git a/testsuite/tests/typecheck/should_fail/fd-loop.stderr b/testsuite/tests/typecheck/should_fail/fd-loop.stderr
index 96fbc3ef18..44a0618181 100644
--- a/testsuite/tests/typecheck/should_fail/fd-loop.stderr
+++ b/testsuite/tests/typecheck/should_fail/fd-loop.stderr
@@ -1,12 +1,12 @@
-
-fd-loop.hs:12:10:
- Variable ‘b’ occurs more often than in the instance head
- in the constraint: C a b
- (Use UndecidableInstances to permit this)
- In the instance declaration for ‘Eq (T a)’
-
-fd-loop.hs:12:10:
- Variable ‘b’ occurs more often than in the instance head
- in the constraint: Eq b
- (Use UndecidableInstances to permit this)
- In the instance declaration for ‘Eq (T a)’
+
+fd-loop.hs:12:10: error:
+ Variable ‘b’ occurs more often
+ in the constraint ‘C a b’ than in the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘Eq (T a)’
+
+fd-loop.hs:12:10: error:
+ Variable ‘b’ occurs more often
+ in the constraint ‘Eq b’ than in the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘Eq (T a)’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail108.stderr b/testsuite/tests/typecheck/should_fail/tcfail108.stderr
index 3a2e5a5657..da766582b3 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail108.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail108.stderr
@@ -1,6 +1,6 @@
tcfail108.hs:7:10: error:
- Variable ‘f’ occurs more often than in the instance head
- in the constraint: Eq (f (Rec f))
+ Variable ‘f’ occurs more often
+ in the constraint ‘Eq (f (Rec f))’ than in the instance head
(Use UndecidableInstances to permit this)
In the instance declaration for ‘Eq (Rec f)’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail154.stderr b/testsuite/tests/typecheck/should_fail/tcfail154.stderr
index 9014b643df..903f61b7de 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail154.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail154.stderr
@@ -1,6 +1,6 @@
-
-tcfail154.hs:12:10:
- Variable ‘a’ occurs more often than in the instance head
- in the constraint: C a a
- (Use UndecidableInstances to permit this)
- In the instance declaration for ‘Eq (T a)’
+
+tcfail154.hs:12:10: error:
+ Variable ‘a’ occurs more often
+ in the constraint ‘C a a’ than in the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘Eq (T a)’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail157.stderr b/testsuite/tests/typecheck/should_fail/tcfail157.stderr
index acdc7df8cf..113e0cc67e 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail157.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail157.stderr
@@ -1,12 +1,12 @@
-
-tcfail157.hs:27:10:
- Variable ‘b’ occurs more often than in the instance head
- in the constraint: E m a b
- (Use UndecidableInstances to permit this)
- In the instance declaration for ‘Foo m (a -> ())’
-
-tcfail157.hs:27:10:
- Variable ‘b’ occurs more often than in the instance head
- in the constraint: Foo m b
- (Use UndecidableInstances to permit this)
- In the instance declaration for ‘Foo m (a -> ())’
+
+tcfail157.hs:27:10: error:
+ Variable ‘b’ occurs more often
+ in the constraint ‘E m a b’ than in the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘Foo m (a -> ())’
+
+tcfail157.hs:27:10: error:
+ Variable ‘b’ occurs more often
+ in the constraint ‘Foo m b’ than in the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘Foo m (a -> ())’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail213.stderr b/testsuite/tests/typecheck/should_fail/tcfail213.stderr
index a6b63bd9f1..a29b758a42 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail213.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail213.stderr
@@ -1,7 +1,7 @@
-
-tcfail213.hs:8:1:
- Illegal constraint ‘F a’ in a superclass/instance context
- (Use UndecidableInstances to permit this)
- In the context: F a
- While checking the super-classes of class ‘C’
- In the class declaration for ‘C’
+
+tcfail213.hs:8:1: error:
+ Illegal constraint ‘F a’ in a superclass context
+ (Use UndecidableInstances to permit this)
+ In the context: F a
+ While checking the super-classes of class ‘C’
+ In the class declaration for ‘C’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail214.stderr b/testsuite/tests/typecheck/should_fail/tcfail214.stderr
index 5520a3eff1..a2741b876b 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail214.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail214.stderr
@@ -1,7 +1,5 @@
-
-tcfail214.hs:9:10:
- Illegal constraint ‘F a’ in a superclass/instance context
- (Use UndecidableInstances to permit this)
- In the context: F a
- While checking an instance declaration
- In the instance declaration for ‘C [a]’
+
+tcfail214.hs:9:10: error:
+ The constraint ‘F a’ is no smaller than the instance head
+ (Use UndecidableInstances to permit this)
+ In the instance declaration for ‘C [a]’
diff --git a/testsuite/tests/typecheck/should_fail/tcfail220.hsig b/testsuite/tests/typecheck/should_fail/tcfail220.hsig
index 129bae368c..560fc317a6 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail220.hsig
+++ b/testsuite/tests/typecheck/should_fail/tcfail220.hsig
@@ -1,5 +1,4 @@
{-# LANGUAGE NoImplicitPrelude #-}
module ShouldFail where
-data Bool a b c d = False
data Maybe a b = Nothing
diff --git a/testsuite/tests/typecheck/should_fail/tcfail220.stderr b/testsuite/tests/typecheck/should_fail/tcfail220.stderr
index 6a4e87382d..432dc4c1a3 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail220.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail220.stderr
@@ -1,17 +1,9 @@
-[1 of 1] Compiling ShouldFail[sig of Prelude] ( tcfail220.hsig, nothing )
-
-tcfail220.hsig:4:1: error:
- Type constructor ‘Bool’ has conflicting definitions in the module
- and its hsig file
- Main module: data Bool = False | True
- Hsig file: type role Bool phantom phantom phantom phantom
- data Bool a b c d = False
- The types have different kinds
-
-tcfail220.hsig:5:1: error:
- Type constructor ‘Maybe’ has conflicting definitions in the module
- and its hsig file
- Main module: data Maybe a = Nothing | Just a
- Hsig file: type role Maybe phantom phantom
- data Maybe a b = Nothing
- The types have different kinds
+[1 of 1] Compiling ShouldFail[sig of Prelude] ( tcfail220.hsig, nothing )
+
+tcfail220.hsig:4:1: error:
+ Type constructor ‘Maybe’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data Maybe a = Nothing | Just a
+ Hsig file: type role Maybe phantom phantom
+ data Maybe a b = Nothing
+ The types have different kinds