[clean-list] Troubles using a function as parameter to
another function
Diederik van Arkel
diederik@cs.kun.nl
Thu, 14 Feb 2002 23:41:36 +0100
op 2/14/02 8:03 PM schreef Claudio Potenza op claudio.potenza@mclink.it:
> After the "more than one Start rule confuses the IDE" problem (that
> was really a bug in the IDE) here is another one:
>
Sorry about that :-(
>
> Unfortunately this involve showing a bit of code; I have tried to reduce
> it to the minimum possible; look at the function "processFiles" in the
> following:
[snip code]
> I get this error:
>
> Uniqueness error [test.icl,5,Start]:"argument 1 of processFiles"
> attribute at indicated position could not be coerced
> (File -> (*File -> ^ *(*Files -> *(String,*File,*Files))))
>
> I have found a workaround for this by playing around with the definition of
> the function "doWork", but it is so ugly I don't want to show it here!
> Another strange fact is that if I defined a function "doWork" that doesn't
> have the "*Files" parameter, but only the two File, it works!
>
> I cannot understand why this happen (and the exact meaning of the error
> message). Am I overlooking something about the uniqueness typing?
>
> thanks
>
>
> Claudio Potenza
> claudio.potenza@mclink.it
>
I'm sure someone else can explain the error you get better than I can. The
easiest solution here is to tuple the function arguments. The following
version compiles without errors:
Start :: *World -> String
Start world = processFiles doWork "input.txt" "out.txt" world
processFiles :: !((File, *File, *Files) -> (String,*File,*Files)) String
String *World -> String
processFiles doWork inputName outputName world = undef
doWork :: (File, *File, *Files) -> (String,*File,*Files)
doWork (inF, outF, files) = undef
Regards,
Diederik van Arkel