Re: O'Haskell OOP Polymorphic Functions

2001-01-17 Thread Ashley Yakeley
OK, I've figured it out. In this O'Haskell statement, > struct Derived < Base = > value :: Int ...Derived is not, in fact, a subtype of Base. Derived and Base are disjoint types, but an implicit map of type "Derived -> Base" has been defined. -- Ashley Yakeley, Seattle WA

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Johan Nordlander
Ashley Yakeley wrote: > > 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,

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Ashley Yakeley
At 2001-01-16 13:18, Magnus Carlsson wrote: >f1 = Just 3 >f2 = f3 = f4 = Nothing So I've declared b = d, but 'theValue b' and 'theValue d' are different because theValue is looking at the static type of its argument? What's to stop 'instance TheValue Base' applying in 'theValue d'? -- Ashley

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Magnus Carlsson
Ashley Yakeley writes: > 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 Basewhere theValue _ = Nothing > > instance TheValue Derived

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Ashley Yakeley
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 Basewhere theValue _ = Nothing > instance TheValue Derived where theValue x = Just (x.value) Doesn't thi

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Johan Nordlander
Magnus Carlsson wrote: > > You can use overloading for the definition of theValue instead: > > class TheValue a where theValue :: a -> Maybe Int > > instance TheValue Basewhere theValue _ = Nothing > instance TheValue Derived where theValue x = Just (x.value) > ... or rather, you wi

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Magnus Carlsson
You can use overloading for the definition of theValue instead: class TheValue a where theValue :: a -> Maybe Int instance TheValue Basewhere theValue _ = Nothing instance TheValue Derived where theValue x = Just (x.value) /M Ashley Yakeley writes: > How do you do OOP-style polymorp

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Ashley Yakeley
At 2001-01-16 00:03, Johan Nordlander wrote: >Ashley Yakeley wrote: >> >> 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 >> the

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Johan Nordlander
Ashley Yakeley wrote: > > 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 _ = No

O'Haskell OOP Polymorphic Functions

2001-01-15 Thread Ashley Yakeley
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 t