[GHC] #10089: feature: warn about unused data definitions (with typeclass instances)
GHC
ghc-devs at haskell.org
Sun Feb 15 13:28:47 UTC 2015
#10089: feature: warn about unused data definitions (with typeclass instances)
-------------------------------------+-------------------------------------
Reporter: slyfox | Owner:
Type: feature | Status: new
request | Milestone:
Priority: normal | Version: 7.8.4
Component: Compiler | Operating System: Unknown/Multiple
Keywords: | Type of failure: None/Unknown
Architecture: | Blocked By:
Unknown/Multiple | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Let's consider an example:
{{{#!hs
-- 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:
1. programmer usually adds a set of data types into their program
(say, 10-15 types to represent an AST)
2. then annotates them with 'deriving (Read, Show)' convenience instances
3. (months later) amends AST representation a bit and leaves
leftover data types not used anywhere
Does that make sense?
Thanks!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10089>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list