[clean-list] questions about uniqueness
Valery
valery at freesurf.fr
Mon Oct 17 20:52:23 MEST 2005
I'm a bit lost with uniqueness typing. Could anyone help me along ?
/1/
Start = (a,f 1 a,f 2 a)
where
f :: !Int *{#Int} -> *{#Int}
f i t
#! t0 = t.[0]
= {t & [0] = t0 + i}
a :: *{#Int}
a = {i \\ i <- [0..9]}
The code above produces ({0,1,2},{1,1,2},{2,1,2}), as if 'a' was not
unique, but I expected it to be rejected by the compiler, because 'f' is
supposed to update its unique argument in place, that is, 'a' should be
destroyed by the first application of 'f, and the second one should fail.
Where am I wrong ? Does 'f' duplicate its array argument despite the
uniqueness annotation ?
/2/
What I want actually is a struct that contains a unique array, because
the array will be updated in place several time later. The struct itself
will be copied, not updated.
When I try
:: Pos = {t :: *{Int}}
I get "inconsistent attribution of type definition", which is fine,
since whatever contains something unique has to be unique, but when I try
:: Pos = *{t :: *{Int}}
I get "} expected instead of ::".
How to define this type ?
Valery
More information about the clean-list
mailing list