News for hackers. Stuff that matters.
Re:From TypeScript to ReScript by lolive on Wednesday January 12, 2022 @08:19AM (#29905963)
I will probably be banned from any Haskell forum after that, but isn't the do notation a async, and the <- a await ?
Re:From TypeScript to ReScript by Zababa on Wednesday January 12, 2022 @12:55PM (#29910396)
It's basically that. Example:

    hello.then(a => return op1(a)).then(b => return op2(b)).then(c => console.log(c);

    const a = await hello();
    const b = await op1(a);
    const c = await op2(b);
    console.log(c)
In Haskell (>>= is pronounced "bind", \a -> is like a => in JS):

    hello >>= (\a -> op1 a >>= (\b -> op2 b >>= (\c -> show c)))

    do {
        a <- hello;
        b <- op1 a;
        c <- op2 b;
        show c
    }
There is a slight difference, in that JS promises aren't monads. But the idea is still here.
Re:From TypeScript to ReScript by nsonha on Wednesday January 12, 2022 @08:24AM (#29906013)
what do you mean by banned? You got it the other way around, async is a special case of the do notation, and await is the special case of <-
Re:From TypeScript to ReScript by rsrsrs86 on Wednesday January 12, 2022 @07:33PM (#29915122)
do { a <- m; return r }

Ia desugared to m >>= (\a -> return r)

Think of it m.then(function (a) return r)