This is really nice, but one thing it leaves to be desired is the ability to applicativelydo over independent stages. E.g. if I have:
const t = Fluture.delay(1000).map(_ => 1)
const x = yield t;
const y = yield t;
return x + y
Neither of the expressions bound to x and y are dependent on each other; thus we can use t.map(x => y => x + y).ap(t) rather than t.chain(x => t.chain(y => x + y)), resulting in the whole thing finishing in 1 second rather than 2. In Haskell (which obviously doesn't have to work under the same constraints as this library), do notation now desugars to the former rather than the latter where possible.
I can't see a way of modeling this with generators, thought maybe you might have some ideas.
This is really nice, but one thing it leaves to be desired is the ability to applicatively
do
over independent stages. E.g. if I have:Neither of the expressions bound to
x
andy
are dependent on each other; thus we can uset.map(x => y => x + y).ap(t)
rather thant.chain(x => t.chain(y => x + y))
, resulting in the whole thing finishing in 1 second rather than 2. In Haskell (which obviously doesn't have to work under the same constraints as this library),do
notation now desugars to the former rather than the latter where possible.I can't see a way of modeling this with generators, thought maybe you might have some ideas.