Uniqueness and overloading
ecceso@eucmos.sim.ucm.es
ecceso@eucmos.sim.ucm.es
Wed, 15 Jan 1997 19:10:21 +0100
I have been playing with clean arrays, and I am astonished because of
an error message. I wanted to copy an array, so I wrote
copy as = {a \\ a<-:as}
The clean compiler accepts this definition and types it as
copy :: (a b) -> *(c b) | Array a & Array c & createArray_u,
defaultArrayvalue, update_u, uselect_u, usize_u b
Then, I tried a function to copy an array with two levels
copy2Levels ass = {copy as \\ as<-:ass}
But I got this error:
Conflicting uniqueness information due to argument2 of createArray
I don't understand why there is a problem with uniqueness. The function
copy returns an unique array. Even more, if I define a restricted version
of copy
copy2 :: (a b) -> *{b} | Array a & createArray_u, defaultArrayvalue, update_u,
uselect_u, usize_u b //This is a restriction of the type inferred by clm.
copy2 as = {a \\ a<-:as}
which returns a fixed class of array, then I can define copy2Levels without
problems
copy2Levels2 ass = {copy2 as \\ as<-:ass}
The type inferred by clm is
copy2Levels2 :: (a (d b)) -> *(c {b}) | Array a & Array c & Array d &
createArray_u, defaultArrayvalue, update_u, uselect_u, usize_u b
I don't understand why overloading interferes with uniqueness.
Are there interactions? Can anyone explain me this?
Or is this only a bug in the type inference algorithm?
Thanks,
Pedro.