diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-11-08 08:52:06 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-11-08 11:12:37 +0000 |
commit | 2c2f3cea93733e0c6dd04e1d891082652dcf5ea1 (patch) | |
tree | c73743cc5639e9a4a233465890e5aa24c07a8093 /testsuite/tests/patsyn | |
parent | 30058b0e45e920319916be999de9c4d77da136e7 (diff) | |
download | haskell-2c2f3cea93733e0c6dd04e1d891082652dcf5ea1.tar.gz |
Minimise provided dictionaries in pattern synonyms
Trac #14394 showed that it's possible to get redundant
constraints in the inferred provided constraints of a pattern
synonym. This patch removes the redundancy with mkMinimalBySCs.
To do this I had to generalise the type of mkMinimalBySCs slightly.
And, to reduce confusing reversal, I made it stable: it now returns
its result in the same order as its input. That led to a raft of
error message wibbles, mostly for the better.
Diffstat (limited to 'testsuite/tests/patsyn')
4 files changed, 30 insertions, 4 deletions
diff --git a/testsuite/tests/patsyn/should_compile/T11213.stderr b/testsuite/tests/patsyn/should_compile/T11213.stderr index a3df05c7a2..ae8f15f4fa 100644 --- a/testsuite/tests/patsyn/should_compile/T11213.stderr +++ b/testsuite/tests/patsyn/should_compile/T11213.stderr @@ -16,24 +16,24 @@ T11213.hs:22:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] T11213.hs:23:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] Pattern synonym with no type signature: - pattern Pur :: forall a. (Num a, Eq a) => a -> [a] + pattern Pur :: forall a. (Eq a, Num a) => a -> [a] T11213.hs:24:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] Pattern synonym with no type signature: pattern Purp :: forall a a1. - (Num a, Eq a) => + (Eq a, Num a) => Show a1 => a -> a1 -> ([a], UnivProv a1) T11213.hs:25:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] Pattern synonym with no type signature: pattern Pure :: forall a. - (Num a, Eq a) => + (Eq a, Num a) => forall a1. a -> a1 -> ([a], Ex) T11213.hs:26:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] Pattern synonym with no type signature: pattern Purep :: forall a. - (Num a, Eq a) => + (Eq a, Num a) => forall a1. Show a1 => a -> a1 -> ([a], ExProv) T11213.hs:27:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)] diff --git a/testsuite/tests/patsyn/should_compile/T14394.script b/testsuite/tests/patsyn/should_compile/T14394.script new file mode 100644 index 0000000000..208df0ca36 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T14394.script @@ -0,0 +1,24 @@ +:set -XPatternSynonyms -XGADTs -XViewPatterns -XScopedTypeVariables + +import Data.Type.Equality + +pattern Foo = HRefl + +:info Foo + +:set -XPolyKinds + +pattern Bar = HRefl +-- Expecting no provided (* ~ *) constraint + +:info Bar + +-- This one generates two Ord a dictionaries +-- but we only need one + +data S a where { MkS :: Ord a => a -> S a } + +pattern Bam x y <- (MkS (x::a), MkS (y::a)) + +:info Bam +-- Expecting only one provided Ord constraint
\ No newline at end of file diff --git a/testsuite/tests/patsyn/should_compile/T14394.stdout b/testsuite/tests/patsyn/should_compile/T14394.stdout new file mode 100644 index 0000000000..0519ecba6e --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T14394.stdout @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T index 8bc9dbdcd9..19c9eaafae 100644 --- a/testsuite/tests/patsyn/should_compile/all.T +++ b/testsuite/tests/patsyn/should_compile/all.T @@ -74,3 +74,4 @@ test('T13768', normal, compile, ['']) test('T14058', [extra_files(['T14058.hs', 'T14058a.hs'])], multimod_compile, ['T14058', '-v0']) test('T14326', normal, compile, ['']) +test('T14394', normal, ghci_script, ['T14394.script']) |