11/08/13 16:06, Rob Arthan wrote:
Poly/ML seems to be a little inconsistent about when it uses type names supplied by the user to abbreviate types as shown in the following transcript:
type COMPLEX = {re : real, im : real};
type COMPLEX = {im: real, re: real}
val unity : COMPLEX = {re = 1.0, im = 0.0};
val unity = {im = 0.0, re = 1.0}: COMPLEX
fun negate ({re, im} : COMPLEX) : COMPLEX = {re = ~re, im = ~im};
val negate = fn: COMPLEX -> {im: real, re: real}
I often find myself putting a type constraint on the right-hand side expression so that Poly/ML prints back the type abbreviation, i.e.
fun negate ({re, im} : COMPLEX) = {re = ~re, im = ~im} : COMPLEX;
I presume that a type annotation on the left-hand side isn't used because it is optional. However, it would be nice if it was.
Regards, Phil