Skip to content

Commit 9cd7e09

Browse files
committed
Merge branch 'master' of github.com:rescript-lang/rescript-lang.org into vlk/add-prettier
2 parents 64beff0 + f70031c commit 9cd7e09

31 files changed

+1816
-1572
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"recommendations": [
3-
"esbenp.prettier-vscode",
4-
"chenglou92.rescript-vscode"
5-
]
6-
}
2+
"recommendations": ["esbenp.prettier-vscode", "chenglou92.rescript-vscode"]
3+
}

_blogposts/2023-09-18-uncurried-mode.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This comes at a price though. Here are some examples to show the drawbacks of cu
3232

3333
- 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
3434
a labeled argument
35+
3536
```diff
3637
@react.component
3738
- let make = (~onChange: string => option<unit => unit>) => {
@@ -45,6 +46,7 @@ This comes at a price though. Here are some examples to show the drawbacks of cu
4546
})
4647
}
4748
```
49+
4850
- If you wanted explicitly uncurry a function, you needed to annotate it with the uncurried dot.
4951
```rescript
5052
(. param) => ()
@@ -53,25 +55,29 @@ This comes at a price though. Here are some examples to show the drawbacks of cu
5355
- 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.
5456
- 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.
5557
1. Have a look at this simple function. It is assigned to `_` because we ignore the resulting `string` value.
58+
5659
```res
5760
let myCurriedFn = (~first) => first
5861
let _ = myCurriedFn(~first="Hello!")
5962
// ^ string
6063
```
6164

6265
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.
66+
6367
```res
6468
let myCurriedFn = (~first, ~second) => first ++ " " ++ second
6569
let _ = myCurriedFn(~first="Hello!")
6670
// ^ (~second: string) => string
6771
```
6872

6973
3. One way to prevent such errors is to annotate the underscore with the function's return type:
74+
7075
```res
7176
let _: string = myCurriedFn(~first="Hello!")
7277
```
7378

7479
4. However, the same issue arises when using the built-in ignore function, which cannot be annotated:
80+
7581
```res
7682
myCurriedFn(~first="Hello!")->ignore
7783
```

0 commit comments

Comments
 (0)