[MLton-user] Compiler Bug?

Matthew Fluet fluet@cs.cornell.edu
Wed, 13 Jul 2005 09:23:32 -0400 (EDT)


> datatype Decimal = Real of real;
> fun decimalEq(Real r1, Real r2) = r1 = r2
> 
> function applied to incorrect argument
>     expects: [<equality>] * [<equality>]
>     but got: [<non-equality>] * [<non-equality>]
>     in: = (r1, r2)
> 
> What causes this problem?

While others have pointed out the problem, you might also be interested in 
the solution:

fun decimalEq(Real r1, Real r2) = Real.== (r1, r2)

which corresponds to IEEE floating-point "=" (meaning that if either 
operand is NAN the result is false).