Control.Print.printDepth := 100;Similarly, include the following lines to print long lists and strings:
Control.Print.printLength := 500; Control.Print.stringDepth := 500;
fun eq(x,y) = (x = y);will cause this warning to be generated, because x and y will have polymorhic type ''a. This is perfectly fine and you may ignore the warning. It is not reporting any kind of semantic error or type error in your code.
The compiler reports the warning because there can be a slight ineffeciency in how ML tests whether two values of a polymorphic type are equal. In particular, to perform the equality test, the run-time system must first determine what types of values you are currently using and then determine whether the values are equal. The first part (checking the run-time types) can make the = test slightly slower than if the types are known ahead of time (such as when we test 3 = 4 and know that the = test is being applied to integers). However, that is not something most users of ML ever need to worry about, and certainly not us. (I'm actually surprised the compiler writers decided to have the compiler generate this warning- previous releases never did.)
fun eq(x,x) = true | eq(x,y) = false;will give you an error.
If you are pattern matching on lists, be sure to handle the nil and non-empty cases. For datatypes, be sure to handle each different constrctor form with its own case.
fun f(x) = let val z = 3; val y = 2 in print z; print y end
fun maptree (LEAF(x)) = ... | ...instead of
fun maptree LEAF(x) = ... | ...
If all else fails, you may find it useful to consult the complete list of SML compiler messages and what they mean.