[Aldor-l] The rejected type is X. Expected type X.
Ralf Hemmecke
ralf at hemmecke.de
Sun Aug 17 10:59:14 EDT 2008
Hi Pippijn,
in case you will be finished with building the aldor compiler, you will
probably have fun with something like this...
Arrrhhhhh.... now I must figure out how to get a workaround...
The interesting thing is ... if I use coerce as is usually done, i.e.
with '::', the error is different.
---coerce variant:
"species.as.nw", line 1083:
for l in lists(coerce(s)$SetSpecies) repeat yield per l;
.......................^
[L1083 C24] #11 (Error) Argument 1 of `lists' did not match any possible
parameter type.
The rejected type is List(Label).
Expected type List(Label).
---:: variant:
"species.as.nw", line 1084:
for l in lists(s :: List L) repeat yield per l;
............^...............^
[L1084 C13] #12 (Error) No meaning for identifier `l'.
[L1084 C29] #11 (Error) There are no suitable meanings for the operator
`coerce'.
The possible types of the left hand side are:
-- SetSpecies
---- For completeness ----
-- I know it is still not everything, but the whole program is
-- simply too long.
LinearOrder(L: LabelType): with {
CombinatorialSpecies;
} == List L add {
Rep == List L;
import from Rep;
local lists(l: List L): Generator List L == generate {
empty? l => yield l;
current := l;
c := first current;
for u in lists(rest l) repeat yield cons(c, u);
assert(not empty? current);
while not empty?(tmp := rest current) repeat {
c := first current;
setRest!(current, rest tmp); -- remove c from l
for u in lists l repeat yield cons(c, u);
setRest!(current, tmp); -- put c back into l
current := tmp;
}
}
structures(s: SetSpecies): Generator % == generate {
import from SetSpecies;
--coerce variant:
-- for l in lists(coerce(s)$SetSpecies) repeat yield per l;
--:: variant
for l in lists(s :: List L) repeat yield per l;
}
...
}
After some minutes ...
Oh, I've just figured out that actually the problem was that I should
have removed the argument of LinearOrder, i.e. with
LinearOrder: with {
the program compiles fine with both variants.
The reason is that I currently refactor my program and thus have a
domain "Label" and a macro
L ==> Label
With that it also becomes clearer why the compiler gives such a strange
error message. After macro expansion the code then reads
LinearOrder(Label: LabelType): with {
CombinatorialSpecies;
} == List Label add {
Rep == List Label;
import from Rep;
local lists(l: List Label): Generator List Label == generate {
... }
structures(s: SetSpecies): Generator % == generate {
...
for l in lists(coerce(s)$SetSpecies) repeat yield per l;
... }
}
Now in SetSpecies there is the function
coerce: % -> List Label;
referring to the domain Label. But the function lists has type
lists: List Label -> Generator List Label
I agree that this is could be considered as a rare instance, but it is
not the first time that this compiler message hit me.
So in order to help people not to waste their time with analysing such a
seemingly useless error message, perhaps there should be a more extended
error message saying that two 'Label' are in scope, one from the
parameter list and another from an earlier domain definition.
Ralf
More information about the Aldor-l
mailing list