Async handler + par combinators
// Multi-capability type: parallel effect composition
// Combines async operations, logging, and error handling
type ParallelProgramCaps = Readonly<{
console: typeof Console.spec;
async: typeof Async.spec;
exception: typeof Exception.spec;
}>;
const program = (): Eff<ParallelSnapshot, ParallelProgramCaps> =>
seq()
.let(() =>
par.all({
console: () => runTask(consoleTask),
state: () => runTask(stateTask),
async: () => runTask(asyncTask),
})
)
.then((results) =>
pipe(descriptors, (descriptors) =>
descriptors.map((descriptor) => results[descriptor.id]))
)
.then((tasks) => ({
tasks,
fastest: pipe(tasks, (ts) =>
ts.reduce((best, current) =>
match(toBoolTag(current.delay < best.delay), {
True: () => current,
False: () => best,
}), tasks[0])
),
}))
.value();
Console output, timeline events will render here after you run the program.
Handlers: Console.capture() · Exception.tryCatch() · Async.default()