Re: O'Haskell OOP Polymorphic Functions

2001-01-30 Thread Fergus Henderson
On 30-Jan-2001, Ashley Yakeley <[EMAIL PROTECTED]> 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. T

Re: O'Haskell OOP Polymorphic Functions

2001-01-30 Thread Fergus Henderson
On 30-Jan-2001, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > Tue, 30 Jan 2001 00:13:41 -0800, Ashley Yakeley <[EMAIL PROTECTED]> pisze: > > > How do I define downcast? > > You can use a non-standard module Dynamic present in ghc, hbc and Hugs > (I don't know if it's compatible with O'H

Re: O'Haskell OOP Polymorphic Functions

2001-01-30 Thread Marcin 'Qrczak' Kowalczyk
Tue, 30 Jan 2001 00:13:41 -0800, Ashley Yakeley <[EMAIL PROTECTED]> pisze: > How do I define downcast? You can use a non-standard module Dynamic present in ghc, hbc and Hugs (I don't know if it's compatible with O'Haskell). -- __("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.

Re: O'Haskell OOP Polymorphic Functions

2001-01-30 Thread 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 hierarch

Re: O'Haskell OOP Polymorphic Functions

2001-01-30 Thread Fergus Henderson
On 30-Jan-2001, Ashley Yakeley <[EMAIL PROTECTED]> 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

Re: O'Haskell OOP Polymorphic Functions

2001-01-29 Thread Ashley Yakeley
At 2001-01-17 17:03, Lennart Augustsson wrote: >You seem to want dynamic type tests. This is another feature, and >sometimes a useful one. But it requires carrying around types at >runtime. Yes. I tried to do that myself by adding a field, but it seems it can't be done. >You might want to lo

Re: O'Haskell OOP Polymorphic Functions

2001-01-17 Thread Lennart Augustsson
Ashley Yakeley wrote: > This seems to be stretching the concept of 'subtype'. I don't think so, this is the essence of subtyping. > Sorry if I sound so bitter and disappointed. I was hoping for a Haskell > extended with real dynamic subtyping... You seem to want dynamic type tests. This is a

Re: O'Haskell OOP Polymorphic Functions

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

Re: O'Haskell OOP Polymorphic Functions

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

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Ashley Yakeley
At 2001-01-16 14:36, Tom Pledger wrote: >Here's a similar example using type-substitution overlapping: > >instance TheValue Char where ... >instance Monad m=> TheValue (m Char) where ... >instance TheValue a => TheValue (Maybe a) where ... > >trouble = theV

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Tom Pledger
Ashley Yakeley writes: [...] > Subtyping-overlapping is quite different from type-substitution > overlapping. Different, but with some similarities. > Consider: > > struct B > > struct D1 < Base = > a1 :: Int > > struct D2 < Base = > a2 :: Int > > class TheValue a w

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Ashley Yakeley
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, the more specific one would never be

Re: O'Haskell OOP Polymorphic Functions

2001-01-16 Thread Tom Pledger
Ashley Yakeley writes: > 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 Th