Re: Polymorphic lists...

2004-03-10 Thread oleg
Hello, Ralf! In fact, he mentions that values can be retrieved by either type or index, while only the former is discussed in detail, if I am right. To me it seems, he would also need to end up using dependant-type encoding of naturals, say data Zero ... and data Succ ..., for look-up. If I

Re: Polymorphic lists...

2004-03-10 Thread MR K P SCHUPKE
Hi Oleg, I like the polymorphic list indexed by Ints... there do seem to be a couple of differences between this and the list indexed by natural numbers. The list indexed by integers cannot determine the type of the return value through induction on the class... in other words it cannot

Re: Polymorphic lists...

2004-03-10 Thread Ralf Laemmel
MR K P SCHUPKE wrote: Hi Oleg, I like the polymorphic list indexed by Ints... there do seem to be a couple of differences between this and the list indexed by natural numbers. ... Agreed with these differences. Another difference: it is initially a heterogeneous set rather than list!

Re: Polymorphic lists...

2004-03-10 Thread MR K P SCHUPKE
This is the latest varient. Let me know whether you guys find this interesting, as I am coding what I need for a practical application, it may be tedious for you... I am still of the opinion that some kind of polygenious list (or maybe heteromorphic?) would be good in the standard libraries,

Re: Polymorphic lists...

2004-03-09 Thread Ralf Laemmel
Hi Kean, looks cool. I get your point about static typing. I guess that adding a fold operator would make your implementation more complete. Oleg has also encountered some of your operations (as you probably know): http://www.haskell.org/pipermail/haskell/2003-August/012355.html (Oleg also

Re: Polymorphic lists...

2004-03-09 Thread MR K P SCHUPKE
I did not know about Oleg's posting, as I originally said, I based my implementation on a paper by Conor McBride. Oleg is addressing the question of type safe casting, rather than generic storage, so his code is a bit different. Infact his class: class TypeSeq t s where type_index:: t - s -

Re: Polymorphic lists...

2004-03-09 Thread MR K P SCHUPKE
I have written a first attempt at a fold function for the heterogenious list: class RFold i r where rFold :: (forall a . a - i - i) - i - r - i instance RFold i RNil where rFold f i RNil = i instance RFold i r = RFold i (a `RCons` r) where rFold f i (x `RCons` xs) = f x (rFold f i xs)

Re: Polymorphic lists...

2004-03-09 Thread MR K P SCHUPKE
I have written a first attempt at a fold function for the heterogenious list: class RFold i r where rFold :: (forall a . a - i - i) - i - r - i instance RFold i RNil where rFold f i RNil = i instance RFold i r = RFold i (a `RCons` r) where rFold f i (x `RCons` xs) = f x (rFold f i xs)

Re: Polymorphic lists...

2004-03-09 Thread Hal Daume III
Though I haven't tried it, the explicit 'Sat' dictionary representation would probably work here, something like: data ShowD a = ShowD { showD :: a - String } -- our explicit dictionary for show, would need one of -- these for each class we care about -- the satisfaction class: class

Re: Polymorphic lists...

2004-03-09 Thread MR K P SCHUPKE
Ok... After playing with these types, I could not get it to work with the satFold below. However it did inspire me to try something else, and this seems to work quite well. First redefine the RFold function to use RFoldFn class as its operator. Then create instances of RFoldFn to do what you

Re: Polymorphic lists...

2004-03-08 Thread Ralf Laemmel
I would like to see your code indeed ... it seems the attachment was missing. Anyway, I am not sure if it obvious or not, but heterogenously typed lists can be nicely modelled with Data.Typeable (!!!) I guess we should add something like this to the module? See

Re: Polymorphic lists...

2004-03-08 Thread MR K P SCHUPKE
Didn't know If I should post it straight away... its quite long and I dont do attachments (well not If I can help it. I am aware Dynamic can model heterogenious lists (thanks for correct terminology) - but I need static typing. Thats the clever thing about this code - the list is heterogenious