#7775: Mark intentionally omitted type class instances
-----------------------------+----------------------------------------------
Reporter:  Lemming           |          Owner:                         
    Type:  feature request   |         Status:  new                    
Priority:  normal            |      Component:  Compiler (Type checker)
 Version:  7.6.2             |       Keywords:  instance warning       
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple       
 Failure:  None/Unknown      |      Blockedby:                         
Blocking:                    |        Related:                         
-----------------------------+----------------------------------------------
 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".

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7775>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-tickets

Reply via email to