MLton 20070826 EqualityType
Home  Index  
An equality type is a type to which PolymorphicEquality can be applied. The Definition and the Basis Library precisely spell out which types are equality types.

To check that a type t is an equality type, use the following idiom.

structure S: sig eqtype t end =
   struct
      type t = ...
   end

Notably, exn and real are not equality types. Neither is t1 -> t2, for any t1 and t2.

Equality on arrays and ref cells is by identity, not structure. For example, ref 13 = ref 13 is false. On the other hand, equality for lists, strings, and vectors is by structure, not identity. For example, the following equalities hold.

[1, 2, 3] = 1 :: [2, 3]
"foo" = concat ["f", "o", "o"]
Vector.fromList [1, 2, 3] = Vector.tabulate (3, fn i => i + 1)


Last edited on 2007-08-15 22:05:47 by MatthewFluet.