Skip to content

method definitions fail to refer to method-context classes

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"

Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information