#1608: Newtype deriving error messages coming out too late
--------------------------------------+-------------------------------------
  Reporter:  simonpj                  |          Owner:  simonpj
      Type:  bug                      |         Status:  new    
  Priority:  normal                   |      Milestone:  6.10   
 Component:  Compiler (Type checker)  |        Version:  6.6.1  
  Severity:  normal                   |       Keywords:         
Difficulty:  Unknown                  |             Os:  Unknown
  Testcase:                           |   Architecture:  Unknown
--------------------------------------+-------------------------------------
Consider this
 {{{
 newtype Ego a = Ego a deriving (Ord)

 f :: Ord a => Ego a -> Ego a -> Bool
 f e1 e2 = e1 < e2
 }}}
 GHC 6.7 reports an error like this:
 {{{
     Could not deduce (Eq (Ego a)) from the context (Ord a)
       arising from a use of `<' at Foo10.hs:6:10-16
     In the expression: e1 < e2
     In the definition of `f': f e1 e2 = e1 < e2
 }}}
 This error should have come when you gave the instance decl.  The reason
 is that GHC's newtype deriving is generating an instance like
 {{{
 instance Eq (Ego a) => Ord (Ego a)
 }}}
 It would make more sense to report the missing instance for Eq right
 there, rather than abstracting over it.

 Thanks to Dougal Stanton for pointing this out:
 http://www.haskell.org/pipermail/haskell-cafe/2007-August/030224.html

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1608>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to