Skip to content

Adapt example tests to Rescript11 + uncurried + RescriptCore #735

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

Merged
merged 9 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compilers/dummy/Dummy.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Console.log("I am a dummy file")
55 changes: 55 additions & 0 deletions compilers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion compilers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@rescript/core": "^0.5.0",
"rescript-820": "npm:bs-platform@8.2.0",
"rescript-902": "npm:bs-platform@9.0.2",
"rescript-912": "npm:rescript@9.1.2",
"rescript-1000": "npm:rescript@10.0.0",
"rescript-1010": "npm:rescript@10.1.0-rc.4"
"rescript-1010": "npm:rescript@10.1.0-rc.4",
"rescript-1100": "npm:rescript@11.0.0-rc.4"
}
}
13 changes: 13 additions & 0 deletions compilers/rescript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "dummy",
"sources": {
"dir": "dummy",
"subdirs": true
},
"bs-dependencies": [
"@rescript/core"
],
"bsc-flags": [
"-open RescriptCore"
]
}
38 changes: 19 additions & 19 deletions pages/docs/manual/latest/api/belt/hash-map.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let make: (~hintSize: int, ~id: id<'key, 'id>) => t<'key, 'value, 'id>
`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @cristianoc is this needed? This isn't pre-compiled into uncurried via MakeHashableU?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the compiler does not come with 2 versions of Belt.
Having to mention a xxxU function in documentation is pretty much a red flag, in that it instantaneously introduces tech debt.
There won't be any xxxU functions in future, so this is a strange point in time to document their use.

@zth do you have any thoughts about the solution here? The thing is, Belt will beed to be replaced with a library that lives outside the compiler, or in any case alongside RescriptCore. What we are witnessing here is simply that this has not happened yet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mid to long term idea for Belt is to be a niche lib living outside of the compiler. This is explicit documentation for Belt, and Belt will be much less needed as Core "takes over".

I'm not sure I have a point here, more an observation. I think we can break Belt out to its own package as soon as we've shipped v11. I guess that would alleviate this particular issue.

Another observation is that Belt will be much less prevalent in docs and examples now that Core exists and we're moving everything to that. So this might not be such a big problem going forward as we think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to @cknitt getting rid of Belt in the compiler is no small feat, but I don't know the full details.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Belt in the compiler can be considered an implementation detail, that can be addressed over time.
I think we can restrict attention to user visible docs for this.

So I guess we can proceed and make a note about next steps in a separate issue.

Copy link
Member

@cknitt cknitt Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristianoc I already started a few attempts to remove Belt from the compiler, but never finished those.

There are two problems:

  1. Pervasives defining stuff based on Belt (type result<'a, 'b> = Belt.Result.t<'a, 'b>).
  2. Belt being used extensively in various tests.

Are you suggesting an approach like the following:

  1. Reverse the dependency from Pervasives to Belt.
  2. Copy Belt into a separate repo and get it to build as a normal ReScript project (this should be rather easy). Publish to npm as @rescript/belt.
  3. Keep Belt in the compiler repo for now so that the tests still work, but do not publish any Belt stuff as part of the rescript npm package anymore, having users use the separate package instead.
  4. Clean up Belt usage in the compiler repo over time.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes something like this sounds like a good approach.

Though I would try to make the compiler's result, not Belt, the source of truth already now.
As otherwise that's going to pop up somewhere, be it hovering in the editor, or some error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -51,7 +51,7 @@ let clear: t<'key, 'value, 'id> => unit
Clears a hash table.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -71,7 +71,7 @@ let isEmpty: t<'a, 'b, 'c> => bool
`isEmpty(m)` checks whether a hash map is empty.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -89,7 +89,7 @@ let set: (t<'key, 'value, 'id>, 'key, 'value) => unit
`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -111,7 +111,7 @@ let copy: t<'key, 'value, 'id> => t<'key, 'value, 'id>
Creates copy of a hash map.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -134,7 +134,7 @@ let get: (t<'key, 'value, 'id>, 'key) => option<'value>
Returns value bound under specific key. If values not exist returns `None`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -156,7 +156,7 @@ let has: (t<'key, 'value, 'id>, 'key) => bool
Checks if `x` is bound in `tbl`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -178,7 +178,7 @@ let remove: (t<'key, 'value, 'id>, 'key) => unit
If bound exists, removes it from the hash map.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand Down Expand Up @@ -207,7 +207,7 @@ let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit
`forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand Down Expand Up @@ -238,7 +238,7 @@ let reduce: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c
The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand Down Expand Up @@ -268,7 +268,7 @@ let keepMapInPlace: (t<'key, 'value, 'id>, ('key, 'value) => option<'value>) =>
Filters out values for which function `f` returned `None`.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -290,7 +290,7 @@ let size: t<'a, 'b, 'c> => int
`size(tbl)` returns the number of bindings in `tbl`. It takes constant time.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -312,7 +312,7 @@ let toArray: t<'key, 'value, 'id> => array<('key, 'value)>
Returns array of key value pairs.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -334,7 +334,7 @@ let keysToArray: t<'key, 'a, 'b> => array<'key>
Returns array of keys.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -356,7 +356,7 @@ let valuesToArray: t<'a, 'value, 'b> => array<'value>
Returns array of values.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -380,7 +380,7 @@ Creates new hash map from array of pairs.
Returns array of values.

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -397,7 +397,7 @@ let mergeMany: (t<'key, 'value, 'id>, array<('key, 'value)>) => unit
```

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -414,7 +414,7 @@ let getBucketHistogram: t<'a, 'b, 'c> => array<int>
```

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand All @@ -432,7 +432,7 @@ let logStats: t<'a, 'b, 'c> => unit
```

```res example
module IntHash = Belt.Id.MakeHashable({
module IntHash = Belt.Id.MakeHashableU({
type t = int
let hash = a => a
let eq = (a, b) => a == b
Expand Down
Loading