Skip to content

Improvements to 'mayLookIdentical'

sheaf requested to merge sheaf/ghc:T26335 into master

Tickets: #26335 (closed) #26340 (closed)

This MR makes significant improvements to the machinery that decides when we should pretty-print the "invisible bits" of a type, such as:

  • kind applications, e.g. @k in Proxy @k ty
  • RuntimeReps, e.g. TYPE r
  • multiplicities and linear arrows a %1 -> b

To do this, this MR refactors mayLookIdentical to return which of the invisible bits don't match up, e.g. in

  (a %1 -> b) ~ (a %Many -> b)

we find that the invisible bit that doesn't match up is a multiplicity, so we should set sdocLinearTypes = True when pretty-printing, and with e.g.

  Proxy @k1 ~ Proxy @k2

we find that the invisible bit that doesn't match up is an invisible TyCon argument, so we set sdocPrintExplicitKinds = True.

We leverage these changes to remove the ad-hoc treatment of linearity of data constructors with dataConDisplayType and dataConNonLinearType. This is now handled by the machinery of pprWithInvisibleBits.

Edited by sheaf

Merge request reports

Loading