module Book = struct
type t = {
isbn: string;
title: string;
}
let compare book_a book_b =
String.compare book_a.isbn book_b.isbn
include Comparator.Make(struct
type nonrec t = t
let compare = compare
end)
end
Now we can create a Set of books:
Set.from_list (module Book) [
{ isbn="9788460767923"; title="Moby Dick or The Whale" }
]