Improve output of failed GeneralizedNewtypeDeriving coercion due to type roles
|Reported by:||haasn||Owned by:||goldfire|
|Component:||Compiler (Type checker)||Version:||7.8.1|
|Type of failure:||None/Unknown||Test Case:||deriving/should_fail/T8984|
|Related Tickets:||Differential Revisions:|
Description (last modified by simonpj)
When trying to build acme-schoenfinkel (as an example), I came across an error like this:
Control/Category/Schoenfinkel.hs:66:48: Could not coerce from ‘cat (cat b c, b) c’ to ‘cat (WrappedSchoenfinkel cat b c, b) c’ because ‘cat (cat b c, b) c’ and ‘cat (WrappedSchoenfinkel cat b c, b) c’ are different types. arising from the coercion of the method ‘app’ from type ‘forall b c. cat (cat b c, b) c’ to type ‘forall b c. WrappedSchoenfinkel cat (WrappedSchoenfinkel cat b c, b) c’ Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself When deriving the instance for (ArrowApply (WrappedSchoenfinkel cat))
It was not immediately clear to me as a user that this was caused due to it wanting GNT which was now being blocked by type roles (rightfully so, as this instance allows UnsafeCoerce!), and beyond that, what the specific rule that triggered this was.
In this case the failure is due to WrappedSchoenfinkel cat b c not being nominally equal to cat b c, in the type (WrappedSchoenfinkel cat b c, b), which is required to be nominally equal to (cat b c, b) because it's used as a parameter to the variable cat.
Printing a location breakdown and context information similar to this to the user would help understanding and debugging roles a lot.
Change History (12)
comment:10 Changed 7 months ago by goldfire
- Owner set to goldfire
- Test Case set to deriving/should_fail/T8984