I figured out in this case, I can just not hop into a |> and just keep it with ->. In general though, is there a way to solve what I was going for above?
let postData = (uri, data) =>
inst->Instance.postData(uri, data)->Promise.Js.fromBsPromise->Promise.Js.map(_x => "")
ReScript is the first language I’ve used that has pipe first so my instinct is to use |>. When the function is unary, it works just as well.
Let’s imagine a scenario where Promise.Js.fromBsPromise takes two argument and the promise is the second argument. That would point me to using |> instead of -> to use that function. Then after that, what would I do to be able to use -> to leverage Proimse.Js.map after that?
You can use _ to place where the left side of the pipe goes with ->, and it is desugared (see the compiled JS. I think it is less expensive than pipe. (they are pretty much the same?)
They are not exactly the same.The → operator is completely desugared on the syntax level, the |> is a normal infix operator function call that happens to get optimized by the compiler later on (that’s why you won’t notice any difference in the JS output).