Ticket #7775 (closed feature request: wontfix)

Opened 2 months ago

Last modified 5 weeks ago

Mark intentionally omitted type class instances

Reported by: Lemming Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.6.2
Keywords: instance warning Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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".

Change History

Changed 2 months ago by monoidal

The "possible fix" message was already removed in 7.6 (#7222).

Changed 5 weeks ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to wontfix

Thanks for the suggestions. However, I think that now that the misleading advice has been removed, it's not worth implementing the pragma, so I'm closing this ticket.

Note: See TracTickets for help on using tickets.