MLton

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.

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