Warning for Typeable instances misplaced
There is currently a warning for hand-rolled instances of Typeable. However, this leads to some pretty surprising error messages: because the instance is ignored any code that relies on that instance in the same module just fails, which appears pretty weird to the user.
import Data.Typeable data K = K instance Typeable K where typeRep _ = undefined ex :: TypeRep ex = typeRep (undefined :: Proxy K)
Gives as an error:
No instance for (Typeable * K) arising from a use of ‛typeRep’ In the expression: typeRep (undefined :: Proxy K) In an equation for ‛ex’: ex = typeRep (undefined :: Proxy K)
Which is of course surprising because the user just defined the instance.
After commenting out the code that uses the instance, one gets:
TypEx.hs:1:1: Warning: Typeable instances can only be derived; ignoring the following instance: instance Typeable * K -- Defined at TypEx.hs:5:10
This information should clearly be somehow presented before or with the previous error if the user is to have any way to figure out what is going on.
I suppose this could be fixed by:
- Turning the Typeable instance warning into an error
- Checking the missing instance in the existing error for Typeable and suggest that the user should look for hand written instances as a source of the problem.