Use IfaceAppArgs to store an IfaceAppTy's arguments

Authored by RyanGlScott on Jul 11 2018, 11:28 AM.

Description

Use IfaceAppArgs to store an IfaceAppTy's arguments

Summary:
Currently, an IfaceAppTy has no way to tell whether its
argument is visible or not, so it simply treats all arguments as
visible, leading to Trac #15330. We already have a solution for this
problem in the form of the IfaceTcArgs data structure, used by
IfaceTyConApp to represent the arguments to a type constructor.
Therefore, it makes sense to reuse this machinery for IfaceAppTy,
so this patch does just that.

This patch:

  1. Renames IfaceTcArgs to IfaceAppArgs to reflect its more general purpose.
  2. Changes the second field of IfaceAppTy from IfaceType to IfaceAppArgs, and propagates the necessary changes through. In particular, pretty-printing an IfaceAppTy now goes through the IfaceAppArgs pretty-printer, which correctly displays arguments as visible or not for free, fixing Trac #15330.
  3. Changes toIfaceTypeX and related functions so that when converting an AppTy to an IfaceAppTy, it flattens as many argument AppTys as possible, and then converts those arguments into an IfaceAppArgs list, using the kind of the function Type as a guide. (Doing so minimizes the number of times we need to call typeKind, which is more expensive that finding the kind of a TyCon.)

Test Plan: make test TEST=T15330

Reviewers: goldfire, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: Trac #15330

Differential Revision: https://phabricator.haskell.org/D4938