The data structure I have in mind involves a record with a member which stores unique strings.
Abstractly this is the record I have in mind:
struct A {
name: string;
neighbors: Set of String;
};
But I can’t seem to create a Set container inside a record in Ocaml. Given that a Set is a functor and not a traditional type, I am not sure how this can be done.
Setis a functor that instantiates a new type for each type of set you want; since it needs to know the comparison function, you can’t dostring setlike you canstring list(unless you usePSet, the polymorphic set, from Batteries Included or extlib). So:With Batteries’ polymorphic sets (be careful with it, as it doesn’t type-check that you’re using the same comparison function):