[clean-list] questions about uniqueness
Diederik van Arkel
dvanarkel at mac.com
Mon Oct 17 22:47:12 MEST 2005
On Oct 17, 2005, at 8:52 PM, Valery wrote:
> 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 ?
This is because 'a' is a function and not a graph definition so each
application of 'a' in your
Start rule produces a new unique array. See section 10.2 from the Clean
2.1 language report for
the details.
> /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 ?
:: *Pos = {t :: *{Int}}
Regards,
Diederik van Arkel
More information about the clean-list
mailing list