Even though tuples, records and discriminated unions are reference types, they all have the built-in equality properties you would expect in a value type. For example:
> let a = (1,'a');; val a : int * char = (1, 'a') > let b = (1,'a');; val b : int * char = (1, 'a') > a = b;; val it : bool = true
That is, you get the equality behavior you would expect rather than the usual equality behavior associated with reference types. Here’s an example of records and the built-in equality checking:
> type rec1 = { a:int b:string };; type rec1 = {a: int; b: string;} > let a = {a=1;b="one"};; val a : rec1 = {a = 1; b = "one";} > let b = {a=1;b="one"};; val b : rec1 = {a = 1; b = "one";} > a = b;; val it : bool = true
Pingback: F# Weekly #34 2013 | Sergey Tihon's Blog