I have the following discriminated union:
type ActCard = Cellar of card list
| Chapel of (card option * card option* card option* card option)
| Smithy | Spy of (card -> bool * card -> bool)
It had structural equality until I added the card -> bool
to Spy
. This question is helpful for how to do custom equality for records. However, I'm not sure how best to implement it in this situation. I would prefer to not have to enumerate each case in ActCard
:
override x.Equals(yobj) =
match x, yobj with
| Spy _, Spy _ -> true
| Cellar cards, Cellar cards2 -> cards = cards2
(* ... etc *)
What is a better approach here?