[m-dev.] New datatype: rope

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Nov 11 16:22:51 AEDT 2010

On Thu, 11 Nov 2010, Peter Schachte wrote:

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

It depends on how much that flexibility costs you.

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