You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;;
The text was updated successfully, but these errors were encountered:
This is intended to address the issue mentioned in
ocaml/ocaml.org#598
This version of the tutorial now demonstrates how to use Set with
arbitrary types. It also provides a demonstration on how to reason
about the behavior of functions based on their type signatures.
avsm
pushed a commit
to avsm/ocaml.org
that referenced
this issue
Dec 16, 2022
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;;
The text was updated successfully, but these errors were encountered: