Concurrify
Turn non-concurrent FantasyLand 3 Applicatives concurrent.
Most time-dependent applicatives are very useful as Monads, because it
gives them the ability to run sequentially, where each step depends on the
previous. However, they lose the ability to run concurrently. This library
allows one to wrap a Monad
(with sequential ap
) in an
Alternative
(with parallel ap
).
Usage
const concurrify = require ('concurrify');
const Future = require ('fluture');
const zero = Future (() => {});
const alt = Future.race;
const ap = (mx, mf) => (Future.both (mx, mf)).map (([x, f]) => f (x));
const ConcurrentFuture = concurrify (Future, zero, alt, ap);
const par = ConcurrentFuture (Future.of (1));
const seq = par.sequential;
seq.fork (console.error, console.log);
Interoperability
API