Today, I got a compiler error when trying to use a lazy pattern when matching on an existential GADT constructor:
An existential or GADT data constructor cannot be used inside a lazy (~) pattern
Why is that limitation? What “bad” stuff could happen, if it were allowed?
Consider
If we could define
then we could have
and thus acquire
and then a crash, rather than the more graceful failure you get when trying to head-normalise the
undefined.GADT data represent evidence about types, so bogus GADT data threaten type safety. It is necessary to be strict with them to validate that evidence: you can’t trust unevaluated computations in the presence of bottom.