Re: O'Haskell OOP Polymorphic Functions
At 2001-01-30 02:37, Fergus Henderson wrote:
class BaseClass s where downcast_to_derived :: s -> Maybe Derived
Exactly what I was trying to avoid, since now every base class needs to know about every derived class. This isn't really a practical way to build an extensible type hierarchy. -- Ashley Yakeley, Seattle WA
On 30-Jan-2001, Ashley Yakeley <ashley@semantic.org> wrote:
At 2001-01-30 02:37, Fergus Henderson wrote:
class BaseClass s where downcast_to_derived :: s -> Maybe Derived
Exactly what I was trying to avoid, since now every base class needs to know about every derived class. This isn't really a practical way to build an extensible type hierarchy.
Right. I don't know of any way to do that in Hugs/ghc without the problem that you mention. Really it needs language support, I think. (I have no idea if you can do it in O'Haskell.) Note that there are some nasty semantic interactions with dynamic loading, which is another feature that it would be nice to support. I think it's possible to add dynamic loading to Haskell 98 without compromising the semantics, but if you support dynamic type class casts, or overlapping instance declarations, then dynamically loading a new module could change the semantics of existing code, rather than just adding new code. -- Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
participants (2)
-
Ashley Yakeley -
Fergus Henderson