On Sat, 16 Jun 2007, "ethan.aubin" < ethan.aubin%2Byahoo%40gmail.com">ethan.aubin+yahoo
gmail.com> wrote:
>
> E.g. say there's a function I expect to be polymorphic with a type
> like 'a -> 'b -> bool, but in the body of the function I have an
> expression which forces 'a='b. Can somehow I stop 'a and 'b from
> being unified? Can I force a compile time error for something like "let
> f (x:'a) (y:'b) : bool = x = y" instead of inferring "f: 'a -> 'a ->
> bool"?
No. If it was possible, then you could write [f 1 "1"]. What should
OCaml do when you reach [1 = "1"] ? Return true or false? According
to what you expect, define you type and the equality on it. You can
also pass an 'equality' (sic) function with type [eq: 'a -> 'b ->
bool] and the inferred type will be the one you want.
ChriS
.