O'Haskell OOP Polymorphic Functions

Ashley Yakeley ashley@semantic.org
Mon, 15 Jan 2001 18:11:09 -0800


How do you do OOP-style polymorphic functions in O'Haskell? My first 
attempt looked something like this:

struct Base

struct Derived < Base = 
     value :: Int

theValue :: Base -> Maybe Int
theValue x = Just (x.value) -- problem line
theValue _ = Nothing

In the problem line, x is considered to be of type Base, so x.value gives 
an error. I tried replacing it with

theValue (x :: Derived) = Just (x.value)

...but that doesn't work either.

-- 
Ashley Yakeley, Seattle WA