In the following, the result type of the function add_abs gets printed out as
{a : int, b : string} rather than as AB:
type AB = {a : int, b : string};
fun add_abs ({a = a1, b = b1} : AB) ({a = a2, b = b2} : AB) : AB = (
{a = a1 + a2, b = b1 ^ b2}
);
structure S1 = struct
type AB = {a : int, b : string};
fun add_abs ({a = a1, b = b1} : AB) ({a = a2, b = b2} : AB) : AB = (
{a = a1 + a2, b = b1 ^ b2}
);
end;
open S1;
To get it to print as AB, you have to do something like the following:
val (add_abs : AB -> AB -> AB) = fn {a = a1, b = b1} => fn {a = a2, b = b2} =>
{a = a1 + a2, b = b1 ^ b2};
(which generates less efficient code, doesn't it?), or:
signature S2 = sig
type AB = {a : int, b : string};
val add_abs : AB -> AB -> AB;
end;
structure S2 : S2 = S1;
This can be quite distracting if you have a structure type with lots of fields
or some other complex type with a familiar name (like the type of tactics in an
LCF-style theorem-prover).
Regards,
Rob._______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml