3 ms·
I have to admit I don't know much about ReScript and only have very basic exposure to OCAML, here is how you do await in it: https://github.com/ocsigen/lwt htt
by nsonha 5y ago
I have to admit I don't know much about ReScript and only have very basic exposure to OCAML, here is how you do await in it:
https://github.com/ocsigen/lwt https://github.com/ocsigen/lwt
The `let* in` is a generic syntax for monads, it doesn't need a special one just for promise. This was in fact a debate back when async/await was in consideration for ECMAScript, but special syntax is hip so now we have `async/await` for Promise, `.?` for optionals and `flatMap` for arrays, basically the same thing.
- ackfoobar 5y agoHaving seen too much `.map(_.map(` in Scala, I'd argue that different words/syntax for different things (that happen to have the same algebraic structure) is a good thing.
- nsonha 5y agoyes but they don't have to be keywords or magical syntax, can be defined in user land
- dmitriid 5y ago> here is how you do await in it That's how you do "await" in a third-party library that brings with it a lot of other baggage. And I doubt it works in ReScript. > The `let* in` is a generic syntax for monads Ah yes. "Just" putting `let*` there magically makes promises work, is that what you're saying? It turns out Lwt gained support for let* sytax only in April 2020. Stupid them. They didn't know they just had to use it.
- ackfoobar 5y ago> It turns out Lwt gained support for let* sytax only in April 2020. I don't understand your point. Monadic let can be done with ppx_let (created in 2016), and even before that there was the older syntax where you write `lwt` instead of `let`. https://github.com/ocsigen/lwt/commit/d28204984646042676570df7ba6b348a635aff58 https://github.com/ocsigen/lwt/commit/d28204984646042676570d...
- dmitriid 5y ago> I don't understand your point. How it started: "In OCAML it's just like any other monad you use the bind operator instead. No need for special keywords." How it's going: "well, there's a third party libary that only recently introduced let*, but before that you had to use either ppx_let [whatever that is — d.] or an older where you use lwt" You listed no less than three special keywords. And one of them specifically introduces a new syntax via ppx. "Just". I find this overuse of the word "just" extremely infuriating. And FP-community is especially guilty of overusing it. "Oh, no need for X, just use <some string of smart-sounding words that is always extremely convoluted, doesn't actually do what X does, comes with caveats the length of the equator etc.>"
- nsonha 5y agothe point is not that there should be no special syntax, but that special syntax in these (functional) languages serves a more generic purpose, and isn't just for async. Ocaml is actually the worst example because it has always relied on extensions to provide an alternative to Haskell's do notation. > well, there's a third party library that only recently introduced let* it won't change how you feel about it but `let*` is an syntax extension (ppx), kinda like babel transform. It has nothing to do with the third party library. What the library provide are async primitives, equivalent of the `q` package in nodejs
- dmitriid 5y agoI can only quote the sibling comment: https://news.ycombinator.com/item?id=29918575 https://news.ycombinator.com/item?id=29918575 --- start quote --- Your point about using "just" is an important one. When you're inside all of that, it seems crystal clear, but for people coming outside of that bubble, it can be quite opaque. --- end quote --- So, your original comment, " In OCAML it's just like any other monad you use the bind operator instead. No need for special keywords." quickly devolved into: - oh, it's not "just a bind operator" - oh, you need special syntax - oh, you need a third party library that may or may not have support for that special syntax So yeah, it's not "just <intellectually superior sounding words>". It never is. Especially in the context of the conversation which is: - ReScript - Requirement to integrate and interoperate with JS and JS libraries that are increasingly Promise-based.