[m-dev.] New datatype: rope

Peter Schachte schachte at csse.unimelb.edu.au
Thu Nov 11 16:18:58 AEDT 2010


On 11/11/10 15:41, Julien Fischer wrote:
> 
> On Thu, 11 Nov 2010, Paul Bone wrote:

>> I don't think typeclasses will give you that either.
>>
>> Perhaps typeclasses and existential types will.

Yup, good point.

> Something like this?
> 
> :- type cord_node
>         --->    some [T] unit_node(T) => seq(T)
>         ;       some [T] list_node(T, list(T)) => seq(T)
>         ;       branch_node(cord_node, cord_node).

No, what I meant was to allow a rope to be made of heterogeneous kinds of
sequences of homogeneous elements.  Eg, a "string" made up of a patchwork of
Mercury strings, lists of characters, individual characters, slices of arrays
of characters.  Ie, I still wanted the type to be cord(T).  But now that I
think of it, I think this would require constructor classes.

> I would question how much you are going to want to mix different kinds
> of sequence in a single rope though.

Do you mean a heterogeneous sequence of elements?  Probably only useful where
all elements are in some type class.  But if you mean a sequence of different
types of sequences of a common element type, this would seem useful to me, and
I can't see why you wouldn't want that flexibility.

-- 
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