O'Haskell OOP Polymorphic Functions
Tue, 30 Jan 2001 21:37:18 +1100
On 30-Jan-2001, Ashley Yakeley <email@example.com> wrote:
> At 2001-01-17 17:03, Lennart Augustsson wrote:
> >You seem to want dynamic type tests.
> >You might want to look at existential types; it is a similar feature.
> I seem to run into a similar problem:
> class BaseClass s
> data Base = forall a. BaseClass a => Base a
> class (BaseClass s) => DerivedClass s
> data Derived = forall a. DerivedClass a => Derived a
> upcast :: Derived -> Base
> upcast (Derived d) = Base d
> downcast :: Base -> Maybe Derived
> How do I define downcast?
class BaseClass s where
downcast_to_derived :: s -> Maybe Derived
Fergus Henderson <firstname.lastname@example.org> | "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.