
At 2001-01-16 14:04, Tom Pledger wrote:
The subtyping (struct Derived < Base ...) makes the two instances overlap, with 'instance TheValue Derived' being strictly more specific than 'instance TheValue Base'. If the system preferred the less specific one, the more specific one would never be used.
This is quite similar to the way overlapping instances are handled when they occur via substitutions for type variables (e.g. 'instance C [Char]' is strictly more specific than 'instance C [a]') in implementations which support than language extension.
Subtyping-overlapping is quite different from type-substitution overlapping. Consider: struct B struct D1 < Base = a1 :: Int struct D2 < Base = a2 :: Int class TheValue a where theValue :: a -> Int instance TheValue B where theValue _ = 0 instance TheValue D1 where theValue _ = 1 instance TheValue D2 where theValue _ = 2 struct M < D1,D2 m = struct a1 = 0 a2 = 0 f = theValue m What's the value of f? -- Ashley Yakeley, Seattle WA