[mercury-users] string

Ralph Becket rbeck at microsoft.com
Sat Dec 4 00:56:05 AEDT 1999


I'm not sure what you want to achieve here.  Do you want to have a class of
strings composed of UNICODE characters?  If so, I suspect that the general
solution to your problem will have to wait for the next version of the
library which should make extensive use of typeclasses.  After all, it
sounds
like you want to pass these string variants to predicates expecting plain
strings.

This does remind me of something I wanted to suggest on this mailing list a
while back.  A couple of times now I've come across the need for a fixed
vector type.  For example, I'm working on a Prolog-like term library where
functors are objects with a name field and a list of arguments.  Since the
arguments are immutable, representing them as lists seems a bit heavyweight
(I use up an extra cons cell for each argument).  Arrays would be handy, but
then you get into all sorts of mode problems (oh for parametric modes!)

Hmm, maybe it'd be an idea to write an immutable vector type module on top
of arrays, using dodgy C stuff to convince the compiler that the vectors
needn't be unique objects.

Ralph

> -----Original Message-----
> From: Michael Day [mailto:mcda at cat.cs.mu.OZ.AU]
> Sent: 03 December 1999 10:08
> 
> does anyone have any ideas on the best way to achieve a 
> string type that
> is parameterized by character type? ie:
> 
> :- type string(T).
> :- type string == string(char).
> 
> given that string is currently a built in type it is not immediately
> obvious to me how to change it in this way, and how many 
> things it would
> break. Two alternatives appear to be defining string to be a list
> (inefficient) or as an array (currently problematic?), 
> however neither of
> those would allow the use of string literals.
> 
> Perhaps this issue can be side stepped by changing the 
> definition of char
> and string to wchar or some other type at the C level, any 
> advice anyone?
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list