In F# you can disable equality or comparison for a type, like this:
[<NoEquality; NoComparison>]
type Contact = {
ContactId : ContactId
PhoneNumber : PhoneNumber
EmailAddress: EmailAddress
}
This is useful for entities which in most cases you do not want to be compared as a whole:
// compiler error!
printfn "%b" (contact1 = contact2)
// ^ the Contact type does not
// support equality
But where you want equality specifically to work on Id fields directly:
// no compiler error
printfn "%b" (contact1.ContactId = contact2.ContactId) // true
Can this be accomplished in ReasonML as well?