[clean-list] Updating unique structures in unique structures in
unique structures
Norbert Zeh
nzeh at cs.dal.ca
Thu May 1 19:13:26 MEST 2008
When I first got to know Clean, I came from the Haskell side and was
impressed that Clean had found a way to make array updates efficient while
maintaining referential transparency. Now I've run into my first round of
problems with unique objects, and I'd appreciate some help. Here's what I
want to do. I want to define a record type one of whose fields is an
array, and I want to be able to update the array. So the array has to be
unique and, therefore, the record type has to be unique:
:: *A = { id :: Int
, a :: *{Int}
}
In a unique array of unique arrays, I could use the replace function to
get a unique reference to one of the arrays stored in the outer array. My
question is: Is there a similar way to get a unique reference to the
elements of a record? The reason why I'd like to do this is that I have a
number of nested unique references of this type. In particular, I have
another record type:
:: *B = { id :: Int
, a :: *{A}
}
So threading my way through the reference hierarchy makes for rather
unreadable code, and I'd like to have a reference to the array inside an
A-record to manipulate it and later patch it back into the A-record.
Thanks,
Norbert
More information about the clean-list
mailing list