Skip to content

Commit 87725e7

Browse files
Add note about it still being experimental
1 parent 6e64f39 commit 87725e7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

_blogposts/2025-09-01-let-unwrap.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ After long discussions we finally decided on an unwrap syntax for both the `opti
1414

1515
Before showing off this new feauture, let's explore why it is useful. Consider a chain of `async` functions that are dependent on the result of the previous one. The naive way to write this in modern ReScript with `async`/`await` is to just `switch` on the results.
1616

17+
**Note**: While we are cautiously optimistic with this implementation of `let?`, we still consider it experimental and thus hide it behind a compiler flag that the user explicitly needs to activate. It might change so use at your own risk.
18+
1719
```res
1820
let getUser = async id =>
1921
switch await fetchUser(id) {
@@ -52,9 +54,9 @@ This is arguably better, more concise, but also harder to understand because we
5254
function getUserPromises(id) {
5355
return Stdlib_Result.flatMapOkAsync(
5456
Stdlib_Result.flatMapOkAsync(fetchUser(id), (user) =>
55-
Promise.resolve(decodeUser(user))
57+
Promise.resolve(decodeUser(user)),
5658
),
57-
ensureUserActive
59+
ensureUserActive,
5860
);
5961
}
6062
```
@@ -93,7 +95,6 @@ async function getUserNestedSwitches(id) {
9395
}
9496
```
9597

96-
9798
## Introducing `let?`
9899

99100
Let's rewrite the above example again with our new syntax:

0 commit comments

Comments
 (0)