Skip to content

Suggestion for the Set tutorial #598

@bnegreve

Description

@bnegreve

If you search the web how to use Sets in OCaml you'll end up on the Set tutorial, which very clearly explain how to make a Set module for String-s like this:
module SS = Set.Make(String);;

Chances are the next thing the next thing you'll try is
module SI = Set.Make(int);;

Which won't work because int is not an OrderedType. It'd be nice to show how to make a set module for arbitrary non-ordered types.

For example, by defining the corresponding OrderedType:

module Int = struct
type t = int
let compare = Pervasives.compare
end;;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions