Tighten checking for associated type instances
This patch finishes off Trac #11450. Following debate on that ticket, the patch tightens up the rules for what the instances of an associated type can look like. Now they must match the instance header exactly. Eg class C a b where type T a x b With this class decl, if we have an instance decl instance C ty1 ty2 where ... then the type instance must look like type T ty1 v ty2 = ... with exactly - 'ty1' for 'a' - 'ty2' for 'b', and - a variable for 'x' For example: instance C [p] Int type T [p] y Int = (p,y,y) Previously we allowed multiple instance equations and now, in effect, we don't since they would all overlap. If you want multiple cases, use an auxiliary type family. This is consistent with the treatment of generic-default instances, and the user manual always said "WARNING: this facility (multiple instance equations may be withdrawn in the future". I also improved error messages, and did other minor refactoring.
Showing
- compiler/rename/RnSource.hs 30 additions, 10 deletionscompiler/rename/RnSource.hs
- compiler/typecheck/TcDeriv.hs 8 additions, 8 deletionscompiler/typecheck/TcDeriv.hs
- compiler/typecheck/TcInstDcls.hs 4 additions, 4 deletionscompiler/typecheck/TcInstDcls.hs
- compiler/typecheck/TcTyClsDecls.hs 7 additions, 6 deletionscompiler/typecheck/TcTyClsDecls.hs
- compiler/typecheck/TcValidity.hs 146 additions, 105 deletionscompiler/typecheck/TcValidity.hs
- compiler/types/Type.hs 0 additions, 12 deletionscompiler/types/Type.hs
- docs/users_guide/glasgow_exts.rst 51 additions, 15 deletionsdocs/users_guide/glasgow_exts.rst
- testsuite/tests/ghci/scripts/T4175.hs 2 additions, 2 deletionstestsuite/tests/ghci/scripts/T4175.hs
- testsuite/tests/ghci/scripts/T4175.stdout 56 additions, 57 deletionstestsuite/tests/ghci/scripts/T4175.stdout
- testsuite/tests/ghci/scripts/T6018ghcifail.stderr 8 additions, 5 deletionstestsuite/tests/ghci/scripts/T6018ghcifail.stderr
- testsuite/tests/indexed-types/should_compile/T10931.hs 1 addition, 1 deletiontestsuite/tests/indexed-types/should_compile/T10931.hs
- testsuite/tests/indexed-types/should_fail/SimpleFail10.hs 2 additions, 1 deletiontestsuite/tests/indexed-types/should_fail/SimpleFail10.hs
- testsuite/tests/indexed-types/should_fail/SimpleFail10.stderr 11 additions, 0 deletions...suite/tests/indexed-types/should_fail/SimpleFail10.stderr
- testsuite/tests/indexed-types/should_fail/SimpleFail9.hs 2 additions, 3 deletionstestsuite/tests/indexed-types/should_fail/SimpleFail9.hs
- testsuite/tests/indexed-types/should_fail/SimpleFail9.stderr 7 additions, 0 deletionstestsuite/tests/indexed-types/should_fail/SimpleFail9.stderr
- testsuite/tests/indexed-types/should_fail/T11450.hs 9 additions, 0 deletionstestsuite/tests/indexed-types/should_fail/T11450.hs
- testsuite/tests/indexed-types/should_fail/T11450.stderr 7 additions, 0 deletionstestsuite/tests/indexed-types/should_fail/T11450.stderr
- testsuite/tests/indexed-types/should_fail/all.T 3 additions, 2 deletionstestsuite/tests/indexed-types/should_fail/all.T
- testsuite/tests/polykinds/T10570.stderr 7 additions, 7 deletionstestsuite/tests/polykinds/T10570.stderr
- testsuite/tests/th/T9692.hs 1 addition, 1 deletiontestsuite/tests/th/T9692.hs
Loading
Please register or sign in to comment