Problem with array updates

Pablo J. Pedemonte ppedemon@sol.info.unlp.edu.ar
Thu, 10 Feb 2000 21:55:55 -0300


Hi! 
I've an annoying problem with the following data structure:

::  VEBTree u = EmptyVEB u
                    | OneVEB u u
	        | TwoVEB u u u
	        | ManyVEB u u u {VEBTree u} (VEBTree u)

It's paramount for this data structure to be efficient to use an array in
the ManyVEB option (instead of a list). But...

I can't mark the array as unique, for I would force the whole VEBTree type
to be unique. In this case, I can't use the function createArray (not even an
array comprehension) to initialize it, for they seem to need a non unique elem
as parameter (I am right?). I get the following error message:

"createArray ({})" attribute at the indicated position cannot be coerced: ^ VEBTree Int

If I instead use the VEBTree tyoe as descripted above (i.e., without uniqueness
annotations), then I can use the createArray function, but I can't update it
destructively: an expression with this form:

  insertWasEmpty (ManyVEB u f l det res) = 
   let 
       a  = ...
       w = ...
       f1 = ...
       l1 = ...
       res1 = ...
   in (ManyVEB u f1 l1 {det & [toInt a] = w} res1)

is rejected by the compiler causing this error:

"argument 1 of update ({})" * attribute required but
not offered at the indicated position: ^ {VEBTree Int} 

This is my very first Clean program, so maybe my problem is naive, I really
don't know...

Anyway, any kind of help, comments and/or suggestions are welcome.
Thanks in advance,

Pablo J. Pedemonte