[m-dev.] New datatype: rope

Peter Schachte schachte at csse.unimelb.edu.au
Thu Nov 11 14:36:05 AEDT 2010


>> how about generalising it by allowing segments of the
>> rope to be made of any instance of a sequence type class?  Then you could make
>> a rope from separate bits of strings, arrays, lists, substrings, basically
>> anything you have lying around that somehow implements a sequential collection
>> of homogeneous things?  I'm not sure what the best set of methods for the type
>> class are, but something equivalent to CAR, CDR, CONS and NIL.
> 
> This is probably okay, provided that you include elem and slice operations and
> probably right-hand-side equivilents of CAR CDR and CONS.

What are "right-hand-side equivilents of CAR CDR and CONS"?

Maybe it would be worth including map, filter and fold in the type class?  Or
maybe just mapreduce?

> I'd also like to see
> more typeclasses in the standard library for collections.  Mutterings have also
> been made about first class, and possibly parametric modules.  That is, rather
> than use type classes use modules that can be parameterised by other modules.
> 
>     import cord(list) as cord_using_lists
>     import cord(slice) as cord_using_slices

But that wouldn't achieve what I was after:  allowing mixing of various kinds
of sequences in a single rope.

-- 
Peter Schachte              Economists are like Aeolian harps, and the
University of Melbourne     sounds that issue from them are determined by
schachte at unimelb.edu.au     the winds that blow.
www.cs.mu.oz.au/~schachte/      -- Rebecca West
Phone: +61 3 8344 1338
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list