O'Haskell OOP Polymorphic Functions
Ashley Yakeley
ashley@semantic.org
Tue, 16 Jan 2001 13:06:54 -0800
At 2001-01-16 10:23, Magnus Carlsson wrote:
>You can use overloading for the definition of theValue instead:
>
> class TheValue a where theValue :: a -> Maybe Int
>
> instance TheValue Base where theValue _ = Nothing
> instance TheValue Derived where theValue x = Just (x.value)
Doesn't this imply that run-time type information is kept with the
structs?
Consider:
d :: Derived
d = struct
value = 3
b :: Base
b = d
idb :: Base -> Base
idb x = x
f1 = theValue d
f2 = theValue b
f3 = theValue (idb d)
f4 = theValue (idb b)
What are the values of f1, f2, f3 & f4?
--
Ashley Yakeley, Seattle WA