Fix #14060 by more conservatively annotating TH-reified types
authorRyan Scott <ryan.gl.scott@gmail.com>
Tue, 15 Aug 2017 00:53:57 +0000 (20:53 -0400)
committerBen Gamari <ben@smart-cactus.org>
Tue, 15 Aug 2017 01:32:11 +0000 (21:32 -0400)
commitad7b945257ea262e3f6f46daa4ff3e451aeeae0b
tree4e6d15f220da4245b7f36efb208a7521ab34e660
parent7c37ffe8f0acd2f72e3d3aeeb517991fa7d45a16
Fix #14060 by more conservatively annotating TH-reified types

Before, TH was quite generous in applying kind annotations to reified
type constructors whose result kind happened to mention type variables.
This could result in agonizingly large reified types, so this patch aims
to quell this a bit by adopting a more nuanced algorithm for determining
when a tycon application deserves a kind annotation.

This implements the algorithm laid out in
https://ghc.haskell.org/trac/ghc/ticket/14060#comment:1. I've updated
`Note [Kind annotations on TyConApps]` to reflect the new wisdom.
Essentially, instead of only checking if the result kind contains free
variables, we also check if any of those variables do not appear free in
injective positions in the argument kinds—only then do we put on a kind
annotation.

Bumps `haddock` submodule.

Test Plan: make test TEST=T14060

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #14060

Differential Revision: https://phabricator.haskell.org/D3807
15 files changed:
compiler/iface/MkIface.hs
compiler/typecheck/FamInst.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcValidity.hs
compiler/types/TyCon.hs
compiler/types/Unify.hs
testsuite/tests/th/T12403.stdout
testsuite/tests/th/T12478_1.stdout
testsuite/tests/th/T14060.hs [new file with mode: 0644]
testsuite/tests/th/T14060.stdout [new file with mode: 0644]
testsuite/tests/th/T8953.stderr
testsuite/tests/th/all.T
utils/haddock