andreypopp / andreypopp/ppx_let_promise
map needs labelled arg, bind doesn't?
- Langage dominant
- OCaml
- Étoiles
- 17
- Forks
- 2
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Just tested ppx_let with BuckleScript, and while `let%bind` was working fine for me, I was struggling getting `let%map` to work.
It seems that
```ocaml
let p = Js.Promise.resolve 1;;
let p1 = let%bind x = p in Js.Promise.resolve (x + 1);;
let p2 = let%map x = p in x + 1;;
```
gets transformed by the ppx to
```ocaml
let p = Js.Promise.resolve 1
let p1 = Let_syntax.bind p (fun x -> Js.Promise.resolve (x + 1))
let p2 = Let_syntax.map p ~f:(fun x -> x + 1)
```
which means that map needs a labelled arg `~f`, but bind doesn't. So the definition of map should actually be
```ocaml
let map promise ~f =
Js.Promise.then_ (fun v -> Js.Promise.resolve (f v)) promise
```
What is super weird is that according to the ppx_let docs, *both* bind and map should require a labelled arg for `f`.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.