Make typeToLHsType produce kind signatures for tycon applications
authorRyan Scott <ryan.gl.scott@gmail.com>
Thu, 4 Jan 2018 01:11:31 +0000 (20:11 -0500)
committerRyan Scott <ryan.gl.scott@gmail.com>
Thu, 4 Jan 2018 01:11:31 +0000 (20:11 -0500)
commit649e777211fe08432900093002547d7358f92d82
treea8951ccb028655b79d467fbebb83242d7c8e0ab1
parent7a25659efc4d22086a9e75dc90e3701c1706c625
Make typeToLHsType produce kind signatures for tycon applications

Summary:
`GeneralizedNewtypeDeriving` generates calls to `coerce`
which take visible type arguments. These types must be produced by
way of `typeToLHsType`, which converts a `Type` to an `LHsType`.
However, `typeToLHsType` was leaving off important kind information
when a `Type` contained a poly-kinded tycon application, leading to
incorrectly generated code in #14579.

This fixes the issue by tweaking `typeToLHsType` to generate
explicit kind signatures for tycon applications. This makes the
generated code noisier, but at least the program from #14579 now
works correctly.

Test Plan: make test TEST=T14579

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14579

Differential Revision: https://phabricator.haskell.org/D4264
compiler/hsSyn/HsUtils.hs
testsuite/tests/deriving/should_compile/T14578.stderr
testsuite/tests/deriving/should_compile/T14579.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T