Fix corner case in typeKind, plus refactoring
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 15 Jun 2018 08:19:55 +0000 (09:19 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 15 Jun 2018 08:47:06 +0000 (09:47 +0100)
commitf903e5510d4562fddef1d4140971e2b93a45e45e
tree9808b0e41fcb5dd2d407c0213dfc2f3ac9d40d54
parent807ab222d08c11a4d00064c9835f9ed9f20ffc7c
Fix corner case in typeKind, plus refactoring

This is a continuation of

    commit 9d600ea68c283b0d38ac663c3cc48baba6b94f57
    Author: Simon Peyton Jones <simonpj@microsoft.com>
    Date:   Fri Jun 1 16:36:57 2018 +0100

        Expand type synonyms when Linting a forall

That patch pointed out that there was a lurking hole in
typeKind, where it could return an ill-scoped kind, because
of not expanding type synonyms enough.

This patch fixes it, quite nicely

* Use occCheckExpand to expand those synonyms (it was always
  designed for that exact purpose), and call it from
         Type.typeKind
         CoreUtils.coreAltType
         CoreLint.lintTYpe

* Consequently, move occCheckExpand from TcUnify.hs to
  Type.hs, and generalise it to take a list of type variables.

I also tidied up lintType a bit.
compiler/coreSyn/CoreLint.hs
compiler/coreSyn/CoreUtils.hs
compiler/typecheck/TcFlatten.hs
compiler/typecheck/TcUnify.hs
compiler/types/Coercion.hs-boot
compiler/types/Type.hs