[m-dev.] New datatype: rope
Paul Bone
pbone at csse.unimelb.edu.au
Thu Nov 11 15:13:03 AEDT 2010
On Thu, Nov 11, 2010 at 02:36:05PM +1100, Peter Schachte wrote:
> >> 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"?
SNOC RAC and RDC.
Given that:
[1, 2, 3] = cons(1, [2, 3])
SNOC is therefore:
[1, 2, 3] = snoc([1, 2], 3)
see cord.snoc/2
> Maybe it would be worth including map, filter and fold in the type class? Or
> maybe just mapreduce?
Probably.
Not just mapreduce, it's ill-defined, what does reduce mean? fold left or fold
right? Associativity is important.
> > 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.
I don't think typeclasses will give you that either.
Perhaps typeclasses and existential types will.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/developers/attachments/20101111/94812406/attachment.sig>
More information about the developers
mailing list