Skip to content
Merged
Changes from 3 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
34 changes: 34 additions & 0 deletions misc_docs/syntax/decorator_uncurry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
id: "uncurry-decorator"
keywords: ["uncurry", "decorator"]
Copy link
Member

Choose a reason for hiding this comment

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

before i forget, one of the keywords should probably also be @bs.uncurry, due to the fact that we will have a lot of users on old versions of ReScript / older blog posts that still use the @bs. prefix convention.

Not a blocker, just wanted to mention

name: "@uncurry"
summary: "This is the `@uncurry` decorator."
category: "decorators"
---

The `@uncurry` decorator allows you to annotate **external** function callback argument types
so when writing the callbacks they may be declared as normal functions `() => { ... }`
rather than needing the uncurried function syntax `(.) => { ... }`.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
@bs.send
external map: (array<'a>, @uncurry ('a => 'b)) => array<'b> = "map"

let result = map([1, 2, 3], x => x + 1)
```

```js
var result = [1, 2, 3].map(function (x) {
return (x + 1) | 0
})
```

</CodeTab>

### References

- [Curry & Uncurry](/docs/manual/latest/bind-to-js-function#curry--uncurry)