Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,970
    • Issues 4,970
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8132
Closed
Open
Created Aug 14, 2013 by scottgw@scottgw

Warning for Typeable instances misplaced

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.

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.
Trac metadata
Trac field Value
Version 7.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking