[GHC] #8132: Warning for Typeable instances misplaced
GHC
ghc-devs at haskell.org
Wed Aug 14 10:22:22 CEST 2013
#8132: Warning for Typeable instances misplaced
-------------------------+-------------------------------------------------
Reporter: | Owner:
scottgw | Status: new
Type: bug | Milestone:
Priority: | Version: 7.7
normal | Operating System: Unknown/Multiple
Component: | Type of failure: Incorrect warning at
Compiler | compile-time
Keywords: | Test Case:
Architecture: | Blocking:
Unknown/Multiple |
Difficulty: |
Unknown |
Blocked By: |
Related Tickets: |
-------------------------+-------------------------------------------------
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.
{{{
#!haskell
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:
1. Turning the Typeable instance warning into an error
2. 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.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8132>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list