Folktale should add a Task.do(generator) function that allows using generators to integrate Task with JavaScript's syntax, like async/await does for promises. In essence, this would allow one to write:
Since people can convert a Task's execution to a promise, they're already able to use async/await, but that requires buying into the disadvantages promises have. In particular, the fact that promises catch errors automatically, and recursively tries to assimilate any object with a .then method may make programs harder to reason about.
Task.do would provide similar syntactical sugar as async/await does, without the semantic drawbacks of promises.
Folktale should add a
Task.do(generator)
function that allows using generators to integrate Task with JavaScript's syntax, likeasync/await
does for promises. In essence, this would allow one to write:Why?
Since people can convert a Task's execution to a promise, they're already able to use
async/await
, but that requires buying into the disadvantages promises have. In particular, the fact that promises catch errors automatically, and recursively tries to assimilate any object with a.then
method may make programs harder to reason about.Task.do
would provide similar syntactical sugar asasync/await
does, without the semantic drawbacks of promises.