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

Type information in Rescript syntax in Docs #239

Merged
merged 8 commits into from
Jan 16, 2022

Conversation

Lomand
Copy link
Contributor

@Lomand Lomand commented Jan 9, 2022

Rescript part of the Docs should have examples and type definitions displayed in Rescript syntax (Right now both are displayed in Ocaml).

Example: 'a -> 'b -> 'c -> 'a * 'b * 'c -> ('a, 'b, 'c) => ('a, 'b, 'c)
People with no experience in Ocaml will find the first version confusing and cryptic.

Since currently there is no way to use Rescript parser programmatically (melange-re/melange#228) the only option is to convert interfaces from .mli to .resi, and read the type information from them. Sound suboptimal, but works surprisingly well (488/499 types converted without a hitch). There were some problems (rescript-lang/syntax#449) with Tablecloth.Map.String and Tablecloth.Set.String type definition (type nonrec 'value t = 'value Of(TableclothString).t), I had to rewrite the type to equivalent

  type identity

  type nonrec 'value t = (TableclothString.t, 'value, identity) t

Since you are in process of refactoring the current implementation (#229) this will no longer be an issue when this PR merges.

There is a need for some testing just to check if everything is alright and also fix broken type definitions in submodules.

I also want to convert all examples in rescript docs to rescript syntax, I'll address this in another PR.

@Lomand
Copy link
Contributor Author

Lomand commented Jan 10, 2022

The PR is ready. The only type that failed to generate is Internal.toBeltComparator. It's not exposed externally in the library, so this issue can be ignored (this type is not displayed in the docs). Other than that, everything is looking normal.

@Lomand Lomand marked this pull request as ready for review January 10, 2022 17:27
@pbiggar
Copy link
Member

pbiggar commented Jan 10, 2022

great, thanks! I looked at it over the weekend, will try to get it merged today.

@pbiggar pbiggar merged commit 9ae8b1f into darklang:next Jan 16, 2022
@pbiggar
Copy link
Member

pbiggar commented Jan 16, 2022

This is great, thank you!

Lomand pushed a commit to Lomand/tablecloth that referenced this pull request Feb 19, 2022
Type information in Rescript syntax in Docs
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