Uniqueness annotations

John van Groningen johnvg@cs.kun.nl
Tue, 2 Mar 1999 17:16:59 +0100


>I seem to have misunderstood the Clean reference manual.
>I _thought_ that if I didn't put a uniqueness variable in front of a
>type, it as as if I _had_, so that
>
>    next_random_list :: !(!RNG_State -> *(b, RNG_State)
>                        ) !Int !RNG_State -> *(*[b], RNG_State)
>
>was identical in effect to
>
>    next_random_list :: !(!RNG_State -> *(u:b, RNG_State)
>                        ) !Int !RNG_State -> *(*[u:b], RNG_State)
>
>but if I understand what you're saying, _each_ occurrence of an
>unqualified type variable gets a _different_ type variable, so that
>it's really like
>
>    next_random_list :: !(!RNG_State -> *(u:b, RNG_State)
>                        ) !Int !RNG_State -> *(*[v:b], RNG_State)
>
>That would explain it.  Thanks.  That does mean that I'm going to
>need a lot of uniqueness variables I thought I could do without.

The compiler will give the the same uniqueness type variable to each occurrence of a type variable (with the same name) when the the type variable is prefixed with a '.'.
So:

    next_random_list :: !(!RNG_State -> *(.b, RNG_State)
                        ) !Int !RNG_State -> (*[.b], RNG_State)


John van Groningen