Make equality constraints in kinds invisible
Issues #12102 (closed) and #15872 (closed) revealed something strange about the way GHC
handles equality constraints in kinds: it treats them as visible
arguments! This causes a litany of strange effects, from strange
error messages
(#12102 (closed) (comment 169035))
to bizarre Eq#
-related things leaking through to GHCi output, even
without any special flags enabled.
This patch is an attempt to contain some of this strangeness. In particular:
- In
TcHsType.etaExpandAlgTyCon
, we propagate through theAnonArgFlag
s of anyAnon
binders. Previously, we were always hard-coding them toVisArg
, which meant that invisible binders (like those whose kinds were equality constraint) would mistakenly get flagged as visible. - In
ToIface.toIfaceAppArgsX
, we previously assumed that the argument to aFunTy
always corresponding to aRequired
argument. We now dispatch on theFunTy
'sAnonArgFlag
and mapVisArg
toRequired
andInvisArg
toInferred
. As a consequence, the iface pretty-printer correctly recognizes that equality coercions are inferred arguments, and as a result, only displays them in-fprint-explicit-kinds
is enabled. - Speaking of iface pretty-printing,
Anon InvisArg
binders were previously being pretty-printed likeT (a :: b ~ c)
, as if they were required. This seemed inconsistent with other invisible arguments (that are printed likeT @{d}
), so I decided to switch this toT @{a :: b ~ c}
.
Along the way, I also cleaned up a minor inaccuracy in the users' guide section for constraints in kinds that was spotted in #12102 (closed) (comment 136220).
Fixes #12102 (closed) and #15872 (closed).