Skip to content

Document how GADT patterns are matched from left-to-right, outside-in

Ryan Scott requested to merge wip/T12018 into master

This adds some bullet points to the GHC User's Guide section on GADTs to explain some subtleties in how GHC typechecks GADT patterns. In particular, this adds examples of programs being rejected for matching on GADTs in a way that does not mesh with GHC's left-to-right, outside-in order for checking patterns, which can result in programs being rejected for seemingly counterintuitive reasons. (See #12018 (closed) for examples of confusion that arose from this.) In addition, now that we have visible type application in data constructor patterns, I mention a possible workaround of using TypeApplications to repair programs of this sort.

Resolves #12018 (closed).

Merge request reports