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

docs(recursion, pattern matching): fix multiple errors of example code #710

Open
wants to merge 3 commits into
base: source
Choose a base branch
from
Open

Conversation

raptazure
Copy link

@raptazure raptazure commented Nov 23, 2020

  1. Example of Recursive Types gives the following compilation error:
Error: Multiple definition of the type name t.
       Names must be unique in a given structure or signature.
  1. Example of More data structures gives Error: Unbound type constructor r. Fixed it by renaming r to point.

@raptazure raptazure changed the title recursion: fix multiple definition of the type name t docs(recursion, pattern matching): fix multiple errors of example code Nov 23, 2020
@kyldvs
Copy link
Contributor

kyldvs commented Dec 2, 2020

Thanks for the PR, for 1. your change kind of defeats the purpose of the example, with different names the nonrec keyword is no longer necessary and could be removed. It's necessary for the types to have the same name in order for this keyword to make sense.

I do not believe the example is an error, but could be one, or perhaps a warning based on your compilation settings: https://sketch.sh/s/p5Bc8Y3L8qoufPo7jxhlGe/

@raptazure
Copy link
Author

Oh, thanks for responding.
I notice that this example works fine with the repl but gives a compilation error when running yarn build. Same with OCaml (utop works fine while ocamlc gives an error). The following code fixes it:

type t = string;
module M = {
  type nonrec t = list(t);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants