[GHC] #9757: Warn about derivable instances
GHC
ghc-devs at haskell.org
Sun Nov 30 20:35:29 UTC 2014
#9757: Warn about derivable instances
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: feature | Status: closed
request | Milestone:
Priority: normal | Version: 7.9
Component: Compiler | Keywords:
Resolution: wontfix | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by goldfire):
I'm not sure if this works with the way HLint is organized, but there is a
decent way of detecting placing where GND can be used: take the Core
produced from the instance definition of a newtype `N` (wrapping
representation type `T`), strip out all coercions, and compare it against
the Core for `T`'s instance. If each method in the instance for `N` is
either a call to the method for `T`'s instance ''or'' symbol-for-symbol
identical to `T`s instance, then GND is suitable.
I think this algorithm would catch the common cases easily enough. But,
like I said, I don't know how well looking at Core code matches with the
way HLint normally goes about its business.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9757#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list