Can I rewrite this function to have the type I requested
instead of failing type checking?
let f : ('a * 'a -> 'a) -> int * bool = fun x -> x (0,1), x (true,false)
I assume the type error is caused by the value restriction.
The parameter (x) becomes monomorphic when applied, so it
can not be applied to both types (int*int) and (bool*bool).
A top level syntactic function
let x : ('a * 'a -> 'a) = fun (a,b) -> a
retains its original, generalized type under similar circumstances.
My real example that fails type checking is more complicated.
I believe the root cause is the same.
--John Carr ([email protected])
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs