6 ms·
In Haskell you can generate a list lazily. The last item in the list could be the final result-value, whereas the leading elements could be the progress informa
by amelius 9y ago
In Haskell you can generate a list lazily. The last item in the list could be the final result-value, whereas the leading elements could be the progress information. Canceling a computation could be done simply by stopping to "listen" to the result (i.e. stopping the evaluation process).
I guess you could implement this in JS by having a promise-like structure which returns a tuple containing progress information AND a promise for the remainder of the computation. In a sense, this is similar to the generator approach.
One problem is if your program execs an external program. At what point should a promise kill the external process?