Type information in Rescript syntax in Docs #239
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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) withTablecloth.Map.String
andTablecloth.Set.String
type definition (type nonrec 'value t = 'value Of(TableclothString).t
), I had to rewrite the type to equivalentSince 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.