[commit: ghc] master: Allow associated types to pattern-match in non-class-bound variables (67345cc)
git at git.haskell.org
git at git.haskell.org
Tue Mar 14 15:31:44 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/67345ccf51538acf2b6452c738ba641b119f5a5e/ghc
>---------------------------------------------------------------
commit 67345ccf51538acf2b6452c738ba641b119f5a5e
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Tue Mar 14 10:58:58 2017 -0400
Allow associated types to pattern-match in non-class-bound variables
Summary:
After 8136a5cbfcd24647f897a2fae9fcbda0b1624035 (#11450), if you have
a class with an associated type:
```
class C a where
type T a b
```
And you try to create an instance of `C` like this:
```
instance C Int where
type T Int Char = Bool
```
Then it is rejected, since you're trying to instantiate the variable ``b`` with
something other than a type variable. But this restriction proves quite
onerous in practice, as it prevents you from doing things like this:
```
class C a where
type T a (b :: Identity c) :: c
instance C Int where
type T Int ('Identity x) = x
```
You have to resort to an auxiliary type family in order to define this now,
which becomes extremely tiring. This lifts this restriction and fixes #13398,
in which it was discovered that adding this restriction broke code in the wild.
Test Plan: ./validate
Reviewers: simonpj, bgamari, austin
Reviewed By: simonpj
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3302
>---------------------------------------------------------------
67345ccf51538acf2b6452c738ba641b119f5a5e
compiler/typecheck/TcValidity.hs | 60 +++++++++++---------
docs/users_guide/8.2.1-notes.rst | 19 +++++++
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/T13398a.hs | 19 +++++++
.../tests/indexed-types/should_compile/T13398b.hs | 12 ++++
testsuite/tests/indexed-types/should_compile/all.T | 2 +
.../indexed-types/should_fail/SimpleFail10.hs | 3 +-
.../indexed-types/should_fail/SimpleFail10.stderr | 11 ----
testsuite/tests/indexed-types/should_fail/all.T | 2 +-
testsuite/tests/th/T9692.hs | 2 +-
testsuite/tests/th/T9692.stderr | 4 +-
.../tests/typecheck/should_fail/T6018fail.stderr | 13 ++---
15 files changed, 125 insertions(+), 114 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 67345ccf51538acf2b6452c738ba641b119f5a5e
More information about the ghc-commits
mailing list