======================================================
class Location a where
point :: a -> Stringclass Packet a where
source, destination :: Location b => a -> b
size :: Num b => a -> b------------------------------------------------------
data TestLocation = TestSource | TestDestination data TestPacket = TestPacket
------------------------------------------------------
instance Location TestLocation where
point a = "location"instance Packet TestPacket where
source p = TestSource
destination p = TestDestination
size p = 99
$ hugs Test.hs
ERROR Test.hs:20 - Inferred type is not general enough
*** Expression : source
*** Expected type : (Packet TestPacket, Location a) => TestPacket -> a
*** Inferred type : (Packet TestPacket, Location TestLocation) => TestPacket -> TestLocation
======================================================
But if i remove source and destination from class and instance definitions alone "size" compiles well.
How write this in a haskell way?
_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
