[clean-list] uniqueness question
Edsko de Vries
edskodevries at gmail.com
Mon Nov 16 17:05:34 MET 2009
Hey,
On 16 Nov 2009, at 15:57, John van Groningen wrote:
> Carlos Aya wrote:
>> Does anyone know why the following type signature is invalid?
>>
>> second :: *a .a -> *a
>> second x y = x
>>
>> I am getting this message
>> Error [matrices.icl,12,second]: a inconsistently attributed (4)
>
> The same uniqueness attribute must be used for all occurrences of
> a type variable in a function type.
>
>> I came across this trying to type a more complex function with arrays, but it boils down to signature above.
>> Why the uniqueness attribute has to be the same for two independent parameters that just happen to have the same type?
>
> A type '*a' cannot be coerced to 'a', because 'a' could be a partial
> application with a unique argument. It this were allowed the unique
> argument could be used more than once. Because the opposite coercion
> (from 'a' to '*a') is also not possible, the compiler requires that
> all occurences of a type variable have the same uniqueness attribute
> (as mentioned above).
While all of that is true, it still does not explain why all occurrences of a type variable need the same attribute. For instance, there is absolutely no problem with
second :: *a .a -> *a
second x y = x
Edsko
More information about the clean-list
mailing list