
On 30-Jan-2001, Ashley Yakeley
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