error-messages
error-messages copied to clipboard
Don't suggest adding constraints to methods and/or functions from other packages
This stackoverflow question shows an error message with a very inappropriate suggestion:
src/LatticePoint.hs:12:14: error:
• No instance for (Eq a)
Possible fix:
add (Eq a) to the context of
the type signature for:
fmap :: forall a b. (a -> b) -> LatticePoint a -> LatticePoint b
• When checking that instance signature for ‘fmap’
is more general than its signature in the class
Instance sig: forall a b.
(Eq a, Eq b) =>
(a -> b) -> LatticePoint a -> LatticePoint b
Class sig: forall a b.
(a -> b) -> LatticePoint a -> LatticePoint b
In the instance declaration for ‘Functor LatticePoint’
|
12 | fmap :: (Eq a, Eq b) => (a -> b) -> LatticePoint a -> LatticePoint b
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think there are at least two things wrong with this message:
- It suggests changing code in another package
- It suggests changing methods of a type class
I'd estimate suggestions that do either of those are very rarely the right way to fix the problem.
My suggestion would be to at least stop this possible fix from being shown and if possible show a better explanation instead.