You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the following attempts to derive instances all produce a compiler error "cannot derive a type class instance for X" and nothing else:
-- Eq has just one type argumentderive instanceeqIntInt :: EqIntInt-- missing the wildcard type argumentderive instancegenericFoo :: Data.Generic.Rep.GenericFoo-- cannot derive this classclassFooderive instancefoo :: Foo
I think it would be nice to provide a little more detail in this error message. Possible reasons the compiler might have failed to derive an instance that I can think of:
It's not aware of the class
The instance was given the wrong number of type arguments (in particular, I think derive instance genericFoo :: Generic Foo missing the second wildcard might be a common mistake)
It's also possible that we might later add more reasons to this list as the compiler is able to derive more instances.
The text was updated successfully, but these errors were encountered:
Ah yeah, I figured the latter one would be fixed by @LiamGoodacre's recent work on instance arity, but of course it won't here as this is arises during in desugaring and doesn't reach the typechecker.
The errors mentioned in there are caught during typechecking instead of desugaring, but the suggestion is to use a message more like when it fails during desugaring, so I think they are different despite the desired result being the same 😄
* Provide an additional reason with the 'cannot derive instance' error, fix#2595
* Clarify error
* Include arity in errors, split out ExpectedTypeConstructor error
Currently the following attempts to derive instances all produce a compiler error "cannot derive a type class instance for X" and nothing else:
I think it would be nice to provide a little more detail in this error message. Possible reasons the compiler might have failed to derive an instance that I can think of:
derive instance genericFoo :: Generic Foo
missing the second wildcard might be a common mistake)It's also possible that we might later add more reasons to this list as the compiler is able to derive more instances.
The text was updated successfully, but these errors were encountered: