contract Compose {
function compose(f,g) {
return lam (x) {
return f(g(x));
} ;
}
function id(x) { return x; }
function idid() { return compose(id,id); }
function main() { return idid(42); }
/*
function main() {
let f = compose(id,id);
return f(42);
}
*/
}
It seems not to be typed right, consequently main gets wrong type:
Typing the call:f
Typing the call:g
Arguments: x :: j
Result for call:g is l
Arguments: g(x) :: l
Result for call:f is k
Before quantify:compose - h -> i -> j -> k
Results: compose :: forall a . h -> i -> j -> a
Typing the call:compose
Arguments: id :: r -> s id :: t -> u
Result for call:compose is j -> p
Before quantify:idid - j -> p
Results: idid :: forall a . j -> a
Typing the call:idid
Arguments: 42 :: Word
Result for call:idid is x
Before quantify:main - x
Results: main :: forall a . a
Before quantify:id - z -> z
Results: id :: z -> z
Also, why compose and main get quantified types, but id does not?
As a sidenote, I would like to write main as commented out, but cannot.
Consider a function composing its arguments:
It seems not to be typed right, consequently main gets wrong type:
Also, why compose and main get quantified types, but id does not?
As a sidenote, I would like to write main as commented out, but cannot.