let compareOn fx (yobj: obj) = match yobj with | :? 'T as y -> compare (fx) (fy) | _ -> invalidArg "yobj" "cannot compare values of different types"
I don't see how the above applies to type x. Why isn't type x just 'a ?
Used in:
type stamp = int [<CustomEquality; CustomComparison>] type MyUnionType = | MyUnionType of stamp * (int -> int) static member Stamp (MyUnionType (s,_)) = s override x.Equals y = equalsOn MyUnionType.Stamp xy override x.GetHashCode() = hashOn MyUnionType.Stamp x interface System.IComparable with member x.CompareTo y = compareOn MyUnionType.Stamp xy
source share