News for hackers. Stuff that matters.
Re:V8 Release v9.4 by Waterluvian on Monday September 06, 2021 @04:37PM (#28437813)
I’m curious if someone can sell me, practically, in relatively few words, what that would gain us compared to Promises today.

That link wasn’t sufficient to teach me. I’m a bit dense. :(

Re:V8 Release v9.4 by hajile on Tuesday September 07, 2021 @09:28AM (#28444561)
Basically, the current promises take a shortcut. If your promise returns a promise, the two promises are automagically combined into one promise.

    foo
    .then(() => returnsAnotherPromise())
    .then(() => { /*only receives the nested promise*/})
The correct solution would not automatically flatmap

    foo
    .then(() => returnsAnotherPromise())
    .then(innerPromise => { 
      innerPromise.then(() = {}) //now we have access to the nested promise
    })
The second API is easier to statically type (creating a type that automatically, but conditionally removes a type is not necessarily0 easy). The second API makes some abstractions easier. The second API more intutitive for most people new to promises (I've seen it done a lot -- especially a few years ago). The second API allows you to interface with other monads without constantly having to do a special conversion any time you touch a promise.

The current API is way more ergonomic for most current developers.

In any case, it seems like there should a way to create your own proper monad promises along with an interface to normal promises when needed.

Re:V8 Release v9.4 by Waterluvian on Tuesday September 07, 2021 @07:41PM (#28451189)
I’m surprised to discover that promise flattening. Never noticed it before. Thanks!