#3958: method definitions fail to refer to method-context classes
-------------------------------+--------------------------------------------
    Reporter:  visionete       |       Owner:                           
        Type:  bug             |      Status:  new                      
    Priority:  normal          |   Component:  Compiler (Type checker)  
     Version:  6.12.1          |    Keywords:                           
          Os:  Linux           |    Testcase:                           
Architecture:  x86_64 (amd64)  |     Failure:  GHC rejects valid program
-------------------------------+--------------------------------------------
 Sorry in advance if this is my lack of understanding...[[BR]]
 The following code fails:[[BR]]

 {{{
 class Cfoo a where
     f :: Int -> a -> Int

 data Foo = F Int

 instance Cfoo Foo where
     f m (F n) = m + n

 data Bar = B Int

 class Cbar a where
     g :: (Cfoo b) => a -> b

 instance Cbar Bar where
     g (B m) = F m
 }}}


 with error:[[BR]]
 {{{
 Couldn't match expected type `b' against inferred type `Foo'
       `b' is a rigid type variable bound by
           the type signature for `g' at [...]
     In the expression: F m
     In the definition of `g': g (B m) = F m
     In the instance declaration for `Cbar Bar'
 }}}
 It's as if the "instance Cfoo Foo" statement is ignored when processing
 "instance CBar Bar"

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