Treat isConstraintKind more consistently
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 25 Jul 2018 10:35:43 +0000 (11:35 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 25 Jul 2018 11:04:30 +0000 (12:04 +0100)
commitc5d31df70b16dc346b5860077c8bbe585ddb7a78
treefc62d0e68fe0b7cda4c2073e598996edc8258030
parentf7d3054a133247cea1f488993695d3cbb941f29d
Treat isConstraintKind more consistently

It turned out that we were not being consistent
about our use of isConstraintKind.

It's delicate, because the typechecker treats Constraint and Type as
/distinct/, whereas they are the /same/ in the rest of the compiler
(Trac #11715).

And had it wrong, which led to Trac #15412.  This patch does the
following:

* Rename isConstraintKind      to tcIsConstraintKind
         returnsConstraintKind to tcReturnsConstraintKind
  to emphasise that they use the 'tcView' view of types.

* Move these functions, and some related ones (tcIsLiftedTypeKind),
  from Kind.hs, to group together in Type.hs, alongside isPredTy.

It feels very unsatisfactory that these 'tcX' functions live in Type,
but it happens because isPredTy is called later in the compiler
too.  But it's a consequence of the 'Constraint vs Type' dilemma.
16 files changed:
compiler/typecheck/ClsInst.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
compiler/types/Kind.hs
compiler/types/TyCoRep.hs
compiler/types/Type.hs
compiler/types/Unify.hs
testsuite/tests/rename/should_fail/T5513.stderr
testsuite/tests/typecheck/should_compile/T15412.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T