Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,260
    • Issues 4,260
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 402
    • Merge Requests 402
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #7775

Closed
Open
Opened Mar 17, 2013 by Lemming@trac-Lemming

Mark intentionally omitted type class instances

In GHCi I get

Prelude> 2+3::Char

<interactive>:2:2:
    No instance for (Num Char)
      arising from a use of `+'
    Possible fix: add an instance declaration for (Num Char)
    In the expression: 2 + 3 :: Char
    In an equation for `it': it = 2 + 3 :: Char

In many cases users now actually try to implement the instance Num Char, but this is certainly not a good idea. I would like to tell the user whenever an instance is intentionally unimplemented and why it is missing. Like so

{-# NOINSTANCE Num Char where "There is no sound arithmetic on characters." #-}

The syntax after NOINSTANCE should be like in an instance declaration. It shall be treated like a type class instance, e.g. it shall be checked whether the same instance already exists, or whether it is orphan, or whether it is not Haskell 98, and it should require to enable according extensions like MultiParamTypeClasses. If on resolution a non-instance is chosen then the compiler should print the custom warning "There is no sound arithmetic on characters." instead of "probable fix: add instance".

Trac metadata
Trac field Value
Version 7.6.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#7775