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, whet
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! (Becaus
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 determin
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.
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 li
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:
>
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 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 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
prefers the term polymorphic lists --- sigh, and he considers
indexing
by types rather than naturals. 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
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 b
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 http://www.cs.vu.nl/boilerplate/tests
I needed a list which could handle items of different types for the
database code I am writing. I have written a module implementing such a
list based on dependant types (from Conor McBride: Faking It; Simulating
Depandant Types in Haskell). Although McBride does not mention
lists/vectors with
13 matches
Mail list logo