[commit: ghc] master: Tighten checking for associated type instances (8136a5c)
git at git.haskell.org
git at git.haskell.org
Tue Apr 19 07:39:33 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/8136a5cbfcd24647f897a2fae9fcbda0b1624035/ghc
>---------------------------------------------------------------
commit 8136a5cbfcd24647f897a2fae9fcbda0b1624035
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Mon Apr 18 15:14:40 2016 +0100
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.
>---------------------------------------------------------------
8136a5cbfcd24647f897a2fae9fcbda0b1624035
compiler/rename/RnSource.hs | 40 +++-
compiler/typecheck/TcDeriv.hs | 16 +-
compiler/typecheck/TcInstDcls.hs | 8 +-
compiler/typecheck/TcTyClsDecls.hs | 13 +-
compiler/typecheck/TcValidity.hs | 251 ++++++++++++---------
compiler/types/Type.hs | 12 -
docs/users_guide/glasgow_exts.rst | 66 ++++--
testsuite/tests/ghci/scripts/T4175.hs | 4 +-
testsuite/tests/ghci/scripts/T4175.stdout | 9 +-
testsuite/tests/ghci/scripts/T6018ghcifail.stderr | 13 +-
.../tests/indexed-types/should_compile/T10931.hs | 2 +-
.../indexed-types/should_fail/SimpleFail10.hs | 3 +-
.../indexed-types/should_fail/SimpleFail10.stderr | 11 +
.../tests/indexed-types/should_fail/SimpleFail9.hs | 5 +-
.../indexed-types/should_fail/SimpleFail9.stderr | 7 +
.../tests/indexed-types/should_fail/T11450.hs | 9 +
.../tests/indexed-types/should_fail/T11450.stderr | 7 +
testsuite/tests/indexed-types/should_fail/all.T | 5 +-
testsuite/tests/polykinds/T10570.stderr | 14 +-
testsuite/tests/th/T9692.hs | 2 +-
testsuite/tests/th/T9692.stderr | 4 +-
testsuite/tests/typecheck/should_fail/T6018fail.hs | 4 +-
.../tests/typecheck/should_fail/T6018fail.stderr | 13 +-
.../typecheck/should_fail/T6018failclosed.stderr | 144 ++++++------
24 files changed, 394 insertions(+), 268 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 8136a5cbfcd24647f897a2fae9fcbda0b1624035
More information about the ghc-commits
mailing list