Skip to content

Add @uncurry decorator syntax lookup #179

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 5 commits into from
Jan 15, 2021
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)