<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all,<br class=""><br class="">As part of my <a href="https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3191" class="">ongoing rework of arrow notation</a>, I have introduced two wired-in type families, which assist in the typechecking process. The details are not terribly important (you can read the proposal if you’d like for those), but the relevant detail is that equalities of the shape<div class=""><br class=""></div><div class=""> ArrowStackTup a ~ b</div><div class=""><br class=""></div><div class="">are produced by the typechecker in key places. ArrowStackTup is one of my wired-in type families, and it’s really an implementation detail. Unfortunately, I often end up with type errors that leak this detail, with expected/actual types like these ones:</div><div class=""><br class=""></div><div class=""><div class=""> Expected type: ArrowStackTup '[Int] -> Bool</div><div class=""> Actual type: Int -> String</div></div><div class=""><br class=""></div><div class="">This is quite annoying, as it’s exceedingly rare that these type families actually get stuck, so they can almost always be expanded in type errors. As it happens, `ArrowStackTup '[a]` expands to simply `a`, so the type error I would like to report is this one:</div><div class=""><br class=""></div><div class=""><div class=""> Expected type: Int -> Bool</div><div class=""> Actual type: Int -> String</div></div><div class=""><br class=""></div><div class="">Not technically challenging, but I find myself faced with the question of where this special expansion logic ought to go. It seems like it could go in any of several places:</div><div class=""><br class=""></div><div class=""><ol class="MailOutline"><li class="">It could be hard-wired into pprType, and perhaps selectively disabled with an -fprint-* flag. This is nice in that it’s universal, but it’s almost certainly a step too far: the casts for ArrowStackTup still end up in Core, and expanding the type synonyms there would be quite confusing.<br class=""><br class=""></li><li class="">The expansion could happen in tidyType, since it’s called before reporting an error. But this seems probably even worse than putting it in pprType, since it’s still used in too many places, and it isn’t supposed to actually change the type.<br class=""><br class=""></li><li class="">It could be handled as an extra, ad-hoc preprocessing step in reportWanteds. This is much closer to reasonable, though it feels like quite a hack.<br class=""><br class=""></li><li class="">A separate error Reporter could catch these errors before the other reporters do and perform the expansion there. But I don’t think this actually makes sense, as the above example demonstrates that ArrowStackTup might be buried inside another type and in fact might not actually be the source of the type error at all!<br class=""><br class=""></li><li class="">It could be done last-minute in mkEqErr. But I don’t know if this is too late, and ArrowStackTup could leak into an error through some other code path.</li></ol><div class=""><br class=""></div></div><div class="">Of those options, the best one I’ve come up with seems to be option 3, an ad-hoc preprocessing step in reportWanteds. Does that seem reasonable? Or is it too much of a kludge?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Alexis</div></body></html>