1
votes

As explained in the REAL signature, real type defined in SML is not an equality type and hence the following expression does not reduces

> 1.0 = 1.0;
poly: : error: Type error in function application.
   Function: = : ''a * ''a -> bool
   Argument: (1.0, 1.0) : real * real
   Reason: Can't unify ''a to real (Requires equality type)

However, this is not handy as datatypes and lists containing reals, lose equality too. I would need to overload polymorphic equality = with Real.== so it could approximately consider reals too.

Is that possible ?

EDIT: Edited question to be more clear

2

2 Answers

3
votes

Did you read Why can't I compare reals in Standard ML and consider the Real.== operator or perform an epsilon test? Have you considered a type like Haskell's Data.Decimal (in which the mantissa and exponent are handled as a pair of Integer)?

1
votes

The simple answer is: no, you can't.