I believe you will need to implement IComparer<T>
for set comprehensions (e.g. Set.of_list
) to work. (Not IComparable<T>
, which tends to be less widely used - though I may be wrong.)
This blog post explains in general how to implement interfaces in F#. It also includes a specific example of a type implementing the IComparer<T>
, which actually isn't straightforward as you might hope.
type Comp() =
interface IComparer with
member x.Compare(a, b) = 0
member x.Compare(a, b) = (x :> IComparer).Compare(a,b)
Let me know if the works for you. I have some suspicion that you might in fact need to implement the IEqualityComparer<T>
instead, since that's what LINQ set extension methods are based around, as far as I know. (It really gets confusing with all these interfaces for comparing in the BCL!)