#1624: internal error caused by adding an instance to a type class with a
functional dependency and a default method
----------------------------------------+-----------------------------------
    Reporter:  int-e                    |        Owner:  simonpj
        Type:  bug                      |       Status:  new    
    Priority:  normal                   |    Milestone:  6.10   
   Component:  Compiler (Type checker)  |      Version:  6.7    
    Severity:  minor                    |   Resolution:         
    Keywords:                           |   Difficulty:  Unknown
          Os:  Linux                    |     Testcase:         
Architecture:  x86                      |  
----------------------------------------+-----------------------------------
Changes (by simonpj):

  * milestone:  => 6.10
  * severity:  normal => minor
  * owner:  => simonpj

Comment:

 Indeed!  This is a well-known problem with fundeps.  The best example is
 {{{
 class Foo a b | a -> b
 instance Foo a (Maybe a)

 foo :: Foo a b => a -> b
 foo = undefined
 }}}
 The instance decl says that for ''any'' first argument `a`, the second
 argument must be `Maybe a`.  But the type sig for `foo` says `foo` has
 type `for all `a,b. a->b`.  But it doesn't hold for all `b`, because `b`
 must be a `Maybe`.

 GHC rejects this because there is no translation into System F.  All this
 will become much clearer when we complete implementing indexed type
 families.

 Meanwhile, I agree that the error message from your first program is
 horribly obscure, so I'll leave this bug open at low priority to improve
 the error message.   It arises because GHC is trying to verify that the
 rhs of the default method for `Foo` has the right type; that is:
 {{{
   undefined :: Foo a b => a -> b
 }}}
 which is an example of the same problem again.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1624>
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