Fix TcUnify.matchExpectedTyConApp so that it returns types of compatible kinds
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 19 Dec 2012 23:49:47 +0000 (23:49 +0000)
committerIan Lynagh <ian@well-typed.com>
Thu, 3 Jan 2013 22:40:31 +0000 (22:40 +0000)
commitc4b2ac3775323948b7a6abdb241a4ad02afa7141
tree2589e528261ecc5bdb65187e6415dccb2b403db4
parent57c8d1c2c8ceba6973a48d138d1bb018ec2988ae
Fix TcUnify.matchExpectedTyConApp so that it returns types of compatible kinds

This fixes Trac #7368. The problem was that we were matching
   Bad w ~ f (Bad f)
where (f :: * -> *).  Thta leads to (w ~ Bad f), which is
ill-kinded, but matchExpectedTyConApp was returning the (Bad f)
as the argument type, and that was being used to instanatiate
w in the data constructor type, which is very bad.

The code also becomes simpler and easier to understand, which is
an excellent thing.
compiler/typecheck/TcUnify.lhs