Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for the Set tutorial #598

Open
bnegreve opened this issue Dec 10, 2014 · 1 comment · May be fixed by #1596
Open

Suggestion for the Set tutorial #598

bnegreve opened this issue Dec 10, 2014 · 1 comment · May be fixed by #1596

Comments

@bnegreve
Copy link

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;;

@NebuPookins
Copy link

I've attempted to fix this problem in https://github.com/ocaml/ocaml.org/pull/1596/commits

NebuPookins referenced this issue in NebuPookins/ocaml.org Jul 18, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants