diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-12-15 14:26:13 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-12-15 14:33:32 +0000 |
commit | 6eabb6ddb7c53784792ee26b1e0657bde7eee7fb (patch) | |
tree | af17a00ab5a30d1ab9a9a11a4786f0f239fe82b4 /testsuite/tests/partial-sigs/should_fail | |
parent | b8ca64592e331005def4f734e026d5418950e6e1 (diff) | |
download | haskell-6eabb6ddb7c53784792ee26b1e0657bde7eee7fb.tar.gz |
Allow recursive (undecidable) superclasses
This patch fulfils the request in Trac #11067, #10318, and #10592,
by lifting the conservative restrictions on superclass constraints.
These restrictions are there (and have been since Haskell was born) to
ensure that the transitive superclasses of a class constraint is a finite
set. However (a) this restriction is conservative, and can be annoying
when there really is no recursion, and (b) sometimes genuinely recursive
superclasses are useful (see the tickets).
Dimitrios and I worked out that there is actually a relatively simple way
to do the job. It’s described in some detail in
Note [The superclass story] in TcCanonical
Note [Expanding superclasses] in TcType
In brief, the idea is to expand superclasses only finitely, but to
iterate (using a loop that already existed) if there are more
superclasses to explore.
Other small things
- I improved grouping of error messages a bit in TcErrors
- I re-centred the haddock.compiler test, which was at 9.8%
above the norm, and which this patch pushed slightly over
Diffstat (limited to 'testsuite/tests/partial-sigs/should_fail')
3 files changed, 5 insertions, 5 deletions
diff --git a/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr b/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr index 2df15443c9..30efb8fc14 100644 --- a/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr +++ b/testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr @@ -2,7 +2,7 @@ InstantiatedNamedWildcardsInConstraints.hs:4:14: error: • Found type wildcard ‘_a’ standing for ‘b’ Where: ‘b’ is a rigid type variable bound by - the inferred type of foo :: (Enum b, Show b) => b -> (String, b) + the inferred type of foo :: (Show b, Enum b) => b -> (String, b) at InstantiatedNamedWildcardsInConstraints.hs:4:8 To use the inferred type, enable PartialTypeSignatures • In the type signature: diff --git a/testsuite/tests/partial-sigs/should_fail/T10999.stderr b/testsuite/tests/partial-sigs/should_fail/T10999.stderr index 408529185f..3244db60ca 100644 --- a/testsuite/tests/partial-sigs/should_fail/T10999.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T10999.stderr @@ -1,7 +1,7 @@ T10999.hs:5:6: error: - Found constraint wildcard ‘_’ standing for ‘(Ord a, - ?callStack::CallStack)’ + Found constraint wildcard ‘_’ standing for ‘(?callStack::CallStack, + Ord a)’ To use the inferred type, enable PartialTypeSignatures In the type signature: f :: _ => () -> _ @@ -10,7 +10,7 @@ T10999.hs:5:17: error: • Found type wildcard ‘_’ standing for ‘Set.Set a’ Where: ‘a’ is a rigid type variable bound by the inferred type of - f :: (Ord a, ?callStack::CallStack) => () -> Set.Set a + f :: (?callStack::CallStack, Ord a) => () -> Set.Set a at T10999.hs:6:1 To use the inferred type, enable PartialTypeSignatures • In the type signature: diff --git a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr index ddbb9e2b6c..ff18935c8d 100644 --- a/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr +++ b/testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr @@ -2,7 +2,7 @@ WildcardInstantiations.hs:5:14: error: • Found type wildcard ‘_a’ standing for ‘a’ Where: ‘a’ is a rigid type variable bound by - the inferred type of foo :: (Enum a, Show a) => a -> String + the inferred type of foo :: (Show a, Enum a) => a -> String at WildcardInstantiations.hs:6:1 To use the inferred type, enable PartialTypeSignatures • In the type signature: |