[clean-list] Bugs in StdOverloadedList
Shivkumar Chandrasekaran
shiv at ece.ucsb.edu
Wed Aug 22 23:22:57 MEST 2007
I tried to use Zip and Unzip from StdOverloadedList hoping to get the
following uniqueness propagation functionalities:
Zip :: !(!.(l a),.(l .b)) -> .(l .(a,.b)) | List l a & List l b &
List l (a,b)
Unzip:: !.(l .(a,.b)) -> .(.(l a),.(l .b)) | List l a & List l b &
List l (a,b)
However using Zip and Unzip in this form was rejected by the
compiler. Ominously I noticed the following lines in
StdOverloadedList.icl:
//Unzip:: !.(l (.a,.b)) -> (.(l .a),.(l .b)) | List l a & List l b &
List l (a,b) // compiler bug ?
//Unzip :: !.(a (.b,.c)) -> (.(d .b),.(e .c)) | List a (b,c) & List e
c & List d b // compiler bug ?
I am not sure if the implementation in StdOverloadedList.icl is a
type inference bug or not. But I know that the following definitions
are being accepted by Clean 2.2 (Mac OS X).
myUnzip :: !.[!.(l,.e)!] -> .([!l!], .[!.e!])
myUnzip [! !] = ([! !], [! !])
myUnzip [! (x,y) : xys !]
#! (x1s, y1s) = myUnzip xys
= ([! x : x1s !], [! y : y1s! ])
myZip :: !.(![!l!], !.[!.e!]) -> .[!.(l,.e)!]
myZip ([!l:ls!], [!e:es!])
#! les = myZip (ls, es)
= [!(l,e): les!]
myZip (_, _) = [!!]
Maybe one of the Clean gurus can comment on this, and if possible,
implement a more generic Zip and Unzip? Thanks,
--shiv--
More information about the clean-list
mailing list