In F#, the equality operator (=) is generally extensional, rather than intensional. That's great! Unfortunately, it appears to me that F# does not use pointer equality to short-cut these extensional comparisons.
For instance, this code:
type Z = MT | NMT of Z ref
// create a Z:
let a = ref MT
// make it point to itself:
a := NMT a
// check to see whether it's equal to itself:
printf "a = a: %A\n" (a = a)
... gives me a big fat segmentation fault[*], despite the fact that 'a' and 'a' both evaluate to the same reference. That's not so great. Other functional languages (e.g. PLT Scheme) get this right, using pointer comparisons conservatively, to return 'true' when it can be determined using a pointer comparison.
So: I'll accept the fact that F#'s equality operator doesn't use short-cutting; is there some way to perform an intensional (pointer-based) equality check? The (==) operator is not defined on my types, and I'd love it if someone could tell me that it's available somehow.
Or tell me that I'm wrong in my analysis of the situation: I'd love that, too...
[*] That would probably be a stack overflow on Windows; there are things about Mono that I'm not that fond of...