Open fvilante opened 4 years ago
Which is better? Result is Better
In bellow code:
const absolve: <E, A>(fr: Future<void, ???<E, A>>) => Future<E, A>
???
should be Result (or Either) instead of Future.
The reason is Result is syncronous, while Future is asynchronous. As absolve
is used many times along normal programming conditions, many Promises
should be required to be chained if we use Future, slowing the computation.
ACTION If I use Result instead of Future could I avoid all this Promises chaining ?
@fvilante you should also consider if run-time does start multiple paralel threads to run promises. If so, for complex computations it should be faster run Promises than run synchronous computations. For simple computations, synchronous calls should still work better.
ACTION
Verify how existent Javascript's Run-time
(ex: node.js, deno.ts, chrome, firefox) deals with schedulling Promises
.
Does the javascript language has by design the requirement for single-threaded event loop
run-time, or this is just a particular design decision of NodeJs.
Absolve
is(or should be) the inverse ofpullout
.Types from Future and ZIO differs.
Question is: 1) What is better? 2) What is the trade-off ?
note: Should
Result
also need the same concept ? Probably all monads which has 2 type parameters.19