Question about uniqueness typing in Clean

Martin Wierich 1wierich@informatik.uni-hamburg.de
Thu, 18 Apr 1996 17:34:03 +0200 (MET DST)


I have a question about uniqueness typing in Clean

I want to simulate a dual-port RAM, that can read and write at the same clock
cycle. So I tried to define a function 'ReadWrite', like follows:


::RAM:=={:Int:}

ReadWrite::*RAM Int        Int         Int         -> (*RAM,Int)
ReadWrite   ram readAdress writeAdress writeValue 
   =let! readValue=ram.[readAdress]
    in   ( {:ram & [writeAdress]=writeValue:},
           readValue)

Start=ReadWrite (createArray 1 4711) 0 0 1996


ReadWrite returns the updated RAM and the read value.
The Compiler reports 'conflicting uniqueness information due to argument 1 of 
_update'.
I'm just beginning using uniqeness typing. Maybe the problem is, that the 
second argument of the result (the read value) contains a reference into the 
first argument (the unique array, that represents the RAM). Could I solve the 
problem by somehow COPYING an element out of the array, so that there is no 
need for a reference ? Or is there any other solution ?