Fix #12369 by being more flexible with data insts
authorRichard Eisenberg <rae@cs.brynmawr.edu>
Wed, 19 Jul 2017 16:28:04 +0000 (12:28 -0400)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Thu, 27 Jul 2017 11:49:06 +0000 (07:49 -0400)
commit4239238306e911803bf61fdda3ad356fd0b42e05
tree098661824130ef59cb0e4f366a6a2030b21c87bd
parent1696dbf4ad0fda4d7c5b4afe1911cab51d7dd0b0
Fix #12369 by being more flexible with data insts

Previously, a data family's kind had to end in `Type`,
and data instances had to list all the type patterns for the
family. However, both of these restrictions were unnecessary:

- A data family's kind can usefully end in a kind variable `k`.
  See examples on #12369.

- A data instance need not list all patterns, much like how a
  GADT-style data declaration need not list all type parameters,
  when a kind signature is in place. This is useful, for example,
  here:

    data family Sing (a :: k)
    data instance Sing :: Bool -> Type where ...

This patch also improved a few error messages, as some error
plumbing had to be moved around.

See new Note [Arity of data families] in FamInstEnv for more
info.

test case: indexed-types/should_compile/T12369
17 files changed:
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcValidity.hs
compiler/types/FamInstEnv.hs
compiler/types/TyCon.hs
compiler/types/Type.hs
docs/users_guide/8.4.1-notes.rst
docs/users_guide/glasgow_exts.rst
testsuite/tests/indexed-types/should_compile/T12369.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/indexed-types/should_fail/ExtraTcsUntch.stderr
testsuite/tests/indexed-types/should_fail/Overlap4.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr
testsuite/tests/indexed-types/should_fail/TyFamArity1.stderr
testsuite/tests/indexed-types/should_fail/TyFamArity2.stderr