Do dependency analysis when kind-checking type declarations
authorsimonpj@microsoft.com <unknown>
Mon, 10 Jan 2011 11:03:51 +0000 (11:03 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 10 Jan 2011 11:03:51 +0000 (11:03 +0000)
commit6ea06bbf08517d9805feb82df65cc56ecbaf23a4
tree0f7d4d11bda62cbe37f3f5842e233e369071c691
parent338cac018258e0c5540e18e0efe7dc84dfce8c86
Do dependency analysis when kind-checking type declarations

This patch fixes Trac #4875.  The main point is to do dependency
analysis on type and class declarations, and kind-check them in
dependency order, so as to improve error messages.

This patch means that a few programs that would typecheck before won't
typecheck any more; but before we were (naughtily) going beyond
Haskell 98 without any language-extension flags, and Trac #4875
convinces me that doing so is a Bad Idea.

Here's an example that won't typecheck any more
       data T a b = MkT (a b)
       type F k = T k Maybe

If you look at T on its own you'd default 'a' to kind *->*;
and then kind-checking would fail on F.

But GHC currently accepts this program beause it looks at
the *occurrences* of T.
compiler/deSugar/DsMeta.hs
compiler/hsSyn/HsDecls.lhs
compiler/hsSyn/HsUtils.lhs
compiler/rename/RnNames.lhs
compiler/rename/RnSource.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcRnDriver.lhs
compiler/typecheck/TcTyClsDecls.lhs
compiler/typecheck/TcTyDecls.lhs
utils/ghctags/Main.hs