Skip to content

Commit c8ad064

Browse files
committed
Merge branch 'master' into playgroud-output-result-rebase-aspeddro
2 parents 8bdb556 + 04878f1 commit c8ad064

File tree

401 files changed

+60203
-13309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

401 files changed

+60203
-13309
lines changed

.babelrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.res linguist-language=ReScript
2+
*.resi linguist-language=ReScript

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ _tempFile.cmj
1515
_tempFile.cmt
1616

1717
# these docs are checked in, but we consider them frozen.
18-
pages/docs/manual/v8.0.0/
19-
pages/docs/manual/v9.0.0/
18+
# pages/docs/manual/v8.0.0/
19+
# pages/docs/manual/v9.0.0/
2020

2121
.bsb.lock
2222
.merlin
@@ -26,3 +26,4 @@ lib/
2626
.vercel
2727

2828
src/**/*.mjs
29+
scripts/**/*.mjs

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ If you need inspiration on what to work on, you can check out issues tagged with
3030

3131
We really appreciate all input from users, community members and potential contributors. Please make sure to consider the other person's opinion and don't assume any common knowledge.
3232

33-
**Most importantly: Keep it professional and be nice to each other**
33+
**Most importantly: Keep it professional and be nice to eachother**
3434

35-
There might be situations where others don't understand a proposed feature or have different opinions on certain writing styles. That's fine, discussions are always welcome! Communicate in clear actionables, make your plans clear and always stick to the original topic.
35+
There might be situations where others don't understand a proposed feature or have different opinions on certain writing styles. That's fine, discussions are always welcome! Communicate in clear actionables, make your plans clear and always to stick to the original topic.
3636

3737
If other contributors disagree with certain proposals and don't change their mind after longer discussions, please don't get discouraged when an issue gets closed / postponed. Everyone tries their best to make the platform better, and to look at it in another perspective: Closed issues are also a highly valuable resource for others to understand technical decisions later on.
3838

3939
### Communicate your Time Commitment
4040

4141
Open Source development can be a challenge to coordinate, so please make sure to block enough time to work on your tasks and show commitment when taking on some work. Let other contributors know if your time schedule changes significantly, and also let others know if you can't finish a task.
4242

43-
We value your voluntary work, and of course it's fine to step back from a ticket for any reason (we can also help you if you are getting stuck). Please talk to us in any case, otherwise we might re-assign the ticket to other contributors.
43+
We value your voluntary work, and of course it's fine to step back from a ticket for any reasons (we can also help you if you are getting stuck). Please talk to us in any case, otherwise we might re-assign the ticket to other contributors.
4444

4545
### Communication Channels
4646

@@ -66,7 +66,7 @@ Always check if there are any designs for certain UI components and think about
6666
### Technical Writing (Documentation)
6767

6868
- Think and write in a JS friendly mindset when explaining concepts / showing examples.
69-
- No `foo` examples if somewhat possible. Try to establish practical context in your showcase examples.
69+
- No `foo` examples if somewhat possible. Try to establish practical context in your show case examples.
7070
- No references to `OCaml`. ReScript is its own language, and we don't rely on external resources of our host language.
7171
- If possible, no references to `Reason` examples / external resources. Our goal is to migrate everything to ReScript syntax.
7272

_blogposts/2020-08-10-bucklescript-is-rebranding.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ There's no dedicated name for the syntax anymore. It's simply called the ReScrip
6161

6262
**Will there be a migration script to gradually convert our code to the new syntax?**
6363

64-
Yes. See our [migration page](/docs/manual/latest/migrate-from-bucklescript-reason). You can mix and match old and new code for a smoother transition.
64+
Yes. See our [migration page](/docs/manual/v10.0.0/migrate-from-bucklescript-reason). You can mix and match old and new code for a smoother transition.
6565

6666
**Will BuckleScript (now ReScript) break my existing code?**
6767

_blogposts/2020-09-25-release-8-3-2.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ There are two ways of removing staled artifacts, the second one is introduced in
8686

8787
- Based on live analysis and prebuilt-in knowledge
8888

89-
We scan `lib/bs` directory and check some dangling cm{i,t,j,ti} files, if it does not exist in
89+
We scan `lib/bs` directory and check some dangling `cm{i,t,j,ti}` files, if it does not exist in
9090
the current build set, it is considered stale artifacts. If it is `cmt` file, it would trigger some hooks of `genType`, notably -cmt-rm.
9191

9292
- Based on previous build logs

_blogposts/2021-02-09-release-9-0.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ReScript is a robustly typed language that compiles to efficient and human-reada
1616

1717
Use `npm` to install the newest [9.0.1 release](https://www.npmjs.com/package/bs-platform/v/9.0.1) with the following command:
1818

19-
```
19+
```sh
2020
npm install bs-platform@9.0.1
2121
```
2222

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
author: rescript-team
3+
date: "2023-09-18"
4+
title: Uncurried Mode
5+
badge: roadmap
6+
description: |
7+
A tour of new capabilities coming to ReScript v11
8+
---
9+
10+
> This is the fourth post covering new capabilities that'll ship in ReScript v11. You can check out the first post on [Better Interop with Customizable Variants](/blog/improving-interop), the second post on [Enhanced Ergonomics for Record Types](/blog/enhanced-ergonomics-for-record-types) and the third post on [First-class Dynamic Import Support](/blog/first-class-dynamic-import-support).
11+
12+
## Introduction
13+
14+
ReScript is a language that strives to keep its users free from experiencing runtime errors. Usually, when a program compiles, it will already do what the user described.
15+
But there is still a concept in the language that makes it easy to let some errors slip through. Currying!
16+
17+
Because of currying, partial application of functions is possible. That feature is always advertised as something really powerful. For instance,
18+
19+
```rescript
20+
let add = (a, b) => a + b
21+
let addFive = add(5)
22+
```
23+
24+
is shorter than having to write all remaining parameters again
25+
26+
```rescript
27+
let add = (a, b) => a + b
28+
let addFive = (b) => add(5, b)
29+
```
30+
31+
This comes at a price though. Here are some examples to show the drawbacks of currying:
32+
33+
* Errors because of changed function signatures have their impact at the use site. Consider this example, where the signature of the onChange function is extended with
34+
a labeled argument
35+
```diff
36+
@react.component
37+
- let make = (~onChange: string => option<unit => unit>) => {
38+
+ let make = (~onChange: (~a: int, string) => option<unit => unit>) => {
39+
React.useEffect(() => {
40+
// As partial application is allowed, there is no error here.
41+
let cleanup = onChange("change")
42+
43+
// Here it errors with "This call is missing an argument of type (~a: int)"
44+
cleanup
45+
})
46+
}
47+
```
48+
* If you wanted explicitly uncurry a function, you needed to annotate it with the uncurried dot.
49+
```rescript
50+
(. param) => ()
51+
```
52+
* As ReScript could not fully statically analyze when to automatically uncurry a function over multiple files, it led to unnecessary `Curry.` calls in the emitted JavaScript code.
53+
* In the standard library (`Belt`), there are both curried and uncurried versions of the same function so you were required to think for yourself when to use the uncurried version and when only the curried one will work.
54+
* In combination with `ignore` / `let _ = ...`, curried can lead to unexpected behavior at runtime after adding a parameter to a function, because you are accidentally ignoring the result of a partial evaluation so that the function is not called at all.
55+
1. Have a look at this simple function. It is assigned to `_` because we ignore the resulting `string` value.
56+
```res
57+
let myCurriedFn = (~first) => first
58+
let _ = myCurriedFn(~first="Hello!")
59+
// ^ string
60+
```
61+
2. Now the function got a second parameter `~second`. Here, the resulting value is a function, which means it is not fully applied and thus never executed.
62+
```res
63+
let myCurriedFn = (~first, ~second) => first ++ " " ++ second
64+
let _ = myCurriedFn(~first="Hello!")
65+
// ^ (~second: string) => string
66+
```
67+
3. One way to prevent such errors is to annotate the underscore with the function's return type:
68+
```res
69+
let _: string = myCurriedFn(~first="Hello!")
70+
```
71+
4. However, the same issue arises when using the built-in ignore function, which cannot be annotated:
72+
```res
73+
myCurriedFn(~first="Hello!")->ignore
74+
```
75+
76+
Those are all only some small paper cuts, but all of them are intricacies that make the language harder to learn.
77+
78+
## Uncurried mode
79+
80+
Starting with ReScript 11, your code will be compiled in uncurried mode. Yes, there is still a way to turn it off ([see below](#how-to-switch-back-to-curried-mode)), but we have decided to already default to this behavior to make it easier for newcomers.
81+
In uncurried mode, the introductory example yields an error:
82+
83+
```rescript
84+
let add = (a, b) => a + b
85+
let addFive = add(5) // <-- Error:
86+
// This uncurried function has type (. int, int) => int
87+
// It is applied with 1 arguments but it requires 2.
88+
```
89+
90+
to fix it, you have two options:
91+
92+
1. state the remaining parameters explicitly
93+
```rescript
94+
let add = (a, b) => a + b
95+
let addFive = (b) => add(5, b)
96+
```
97+
2. or use the new explicit syntax for partial application
98+
```rescript
99+
let add = (a, b) => a + b
100+
let addFive = add(5, ...)
101+
```
102+
103+
The former approach helps library authors support both ReScript 11 and earlier versions.
104+
105+
### No final unit anymore
106+
107+
We are happy to announce that with uncurried mode the "final unit" pattern is not necessary anymore, while you still can use optional or default parameters.
108+
109+
```res
110+
// old
111+
let myFun = (~name=?, ())
112+
113+
// new
114+
let myFun = (~name=?)
115+
```
116+
117+
### More wins
118+
119+
Furthermore, function calls in uncurried mode are now guaranteed to get compiled as simple JavaScript function calls, which is quite nice for readability of the generated code.
120+
It may also give you some (negligible) performance gains.
121+
122+
### How to switch back to curried mode
123+
124+
While we strongly encourage all users to switch to the new uncurried mode, it is still possible to opt out. Just add a
125+
126+
```json
127+
{
128+
"uncurried": false
129+
}
130+
```
131+
132+
to your `bsconfig.json`, and your project will be compiled in curried mode again.
133+
134+
If you have uncurried mode off and still want to try it on a per-file basis, you can turn it on via
135+
136+
```rescript
137+
@@uncurried
138+
```
139+
140+
at the top of a `.res` file.
141+
142+
## Conclusion
143+
144+
Many thoughts have led to this decision, but we think this change is a great fit for a compile-to-JS language overall. If you are interested in the details, have a look at the corresponding [forum post](https://forum.rescript-lang.org/t/uncurried-by-default/) and its comments.
145+
146+
We hope that this new way of writing ReScript will make it both easier for beginners and also more enjoyable for the seasoned developers.
147+
148+
As always, we're eager to hear about your experiences with our new features. Feel free to share your thoughts and feedback with us on our [issue tracker](https://github.com/rescript-lang/rescript-compiler/issues) or on the [forum](https://forum.rescript-lang.org).
149+
150+
Happy hacking!

_blogposts/archive/2017-10-09-bucklescript-release-1-7-5.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A detailed list of changes are listed as below:
2626
- #1658, fix typeof = "null" issue
2727
- #1656, bs.get/set/get_index/set_index respects bs.ignore
2828
- #1654, `bsb -init` fails if package or current dir has space (parent dir can have spaces)
29-
- #1678, bs.get{null;undefined} in object type
29+
- #1678, `bs.get{null;undefined}` in object type
3030
- #1692, fix invalid js syntax output
3131
- #1701, fix tailcall handling interaction with exception handler
3232
- #1666, fix misue of GADT api

compilers/dummy/Dummy.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Console.log("I am a dummy file")

compilers/package-lock.json

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compilers/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
"main": "index.js",
66
"license": "MIT",
77
"dependencies": {
8+
"@rescript/core": "^0.6.0",
9+
"rescript-1000": "npm:rescript@10.0.0",
10+
"rescript-1010": "npm:rescript@10.1.0-rc.4",
11+
"rescript-1100": "npm:rescript@11.0.0-rc.8",
812
"rescript-820": "npm:bs-platform@8.2.0",
913
"rescript-902": "npm:bs-platform@9.0.2",
10-
"rescript-912": "npm:rescript@9.1.2",
11-
"rescript-1000": "npm:rescript@10.0.0",
12-
"rescript-1010": "npm:rescript@10.1.0-rc.4"
14+
"rescript-912": "npm:rescript@9.1.2"
1315
}
1416
}

compilers/rescript.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "dummy",
3+
"sources": {
4+
"dir": "dummy",
5+
"subdirs": true
6+
},
7+
"bs-dependencies": [
8+
"@rescript/core"
9+
],
10+
"bsc-flags": [
11+
"-open RescriptCore"
12+
]
13+
}

data/sidebar_manual_latest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"Overview": [
33
"introduction",
44
"installation",
5+
"migrate-to-v11",
56
"editor-plugins",
6-
"migrate-from-bucklescript-reason",
77
"try"
88
],
99
"Language Features": [
@@ -31,7 +31,6 @@
3131
"module",
3232
"import-export",
3333
"attribute",
34-
"unboxed",
3534
"reserved-keywords"
3635
],
3736
"Advanced Features": [

0 commit comments

Comments
 (0)