feature: warn about unused data definitions (with typeclass instances)
Let's consider an example:
-- M.hs: module M () where -- ghc knows about uselessness of those data D = D -- but doesn't about this: data E = E deriving (Show, Read)
ghc warns about useless D, but not E:
$ ghc-7.8.4 -Wall -c M.hs -fforce-recomp M.hs:5:1: Warning: Defined but not used: type constructor or class ‘D’ M.hs:5:10: Warning: Defined but not used: data constructor ‘D’
There is no way to refer to E type outside or call it's unstances, correct?
I would expect no code should be generated for this module.
ghc could also warn about defined, but not used instances for types, that are not exported.
Some background on where those stray types come from:
- programmer usually adds a set of data types into their program
(say, 10-15 types to represent an AST)
- then annotates them with 'deriving (Read, Show)' convenience instances
- (months later) amends AST representation a bit and leaves
leftover data types not used anywhere
Does that make sense?