When migrating from a C# world to an F# (the most idiomatic possible) mindset, I've found this interesting difference.
In C#'s OOP&mutable world, the default set collection seems to be HashSet, which seems to be not sorted by default (because the comparer that it accepts is just for equality); while if you wanted a sorted one you would have to use SortedSet.
However in F#'s world, the basic set
is already sorted because it requires the element type used to implement equality and comparison. Any specific reason for this? Why not having an unordered set in the main collections for this language?
As a side-note, I'm wondering if it'd be possible to have a set collection that didn't allow duplicates, but that had a preference over certain elements when discarding some elements as duplicates. Example: a record { Name: string; Flag: Option<unit> }
so that when inserting { Name = "foo"; Flag = None }
and later { Name = "foo"; Flag = Some() }
it ended up containing only the latter element (because Flag is present).