Allow WARNING pragma on instances
Motivation
In a software project, some instances should maybe never be implemented, for instance Eq
on very large data structures.
I can ensure this by giving a dummy implementation like:
instance Eq D where
(==) = undefined
However, this gives me only a runtime error, but I wish to get a compile-time error if trying to use equality on D
, just as if I hadn't implemented an instance in the first place.
I could get a compile-time alert if it was possible to attach WARNING or DEPRECATED pragmas to instances or method implementations.
Proposal
Allow WARNING and DEPRECATED on instances, e.g.:
instance Eq D {-# WARNING: "No equality on D!" #-} where
(==) = undefined
The behavior should be similar to a missing implementation of Eq D
, i.e., a warning generated during type-checking.
Maybe it is possible to throw a hard error also? (I did not find an ERROR pragma.)
Edited by Andreas Abel