The value the effect produces.
Capture a throw as data: an IO that runs this one and produces an
Except, ok holding the value or failed holding what was thrown.
A throw anywhere in the chain built before attempt (the effect, a map
or tap function, a bind step) becomes a failed Except, so run() of
the result never throws. A non-Error throw is wrapped as
Except.tryCatch wraps it, with the original as cause. A function
chained after attempt throws from run() as usual. A promise the IO
returns is not awaited, so attempt does not capture its rejection; use
AsyncIO#attempt for that.
This is Haskell's try (Control.Exception), renamed because try reads as
the statement.
An IO that produces ok holding this IO's value, or failed
holding the error it threw.
Perform the side effect and return its result.
Haskell has no safe equivalent: its runtime runs main, and the nearest
function is unsafePerformIO, so call run() only at the program's edge.
The value the effect produces.
Perform an additional side effect with the current value, keeping the original result.
If sideEffect throws, the error is thrown from run().
Haskell has no direct counterpart; the nearest is
io >>= \a -> f a >> pure a.
The effect to perform with the value; its return is ignored.
An IO that produces this IO's value after sideEffect runs.
StaticdoBuild an IO from a do block: Haskell's do notation, with x <- m
written const x = yield* m.
Each yield* m binds the value m produces, typed with no annotation.
Nothing in the block runs until run() is called, and every run() starts
the block afresh. A throw in the block is thrown from run(). A plain
yield (without *) binds unknown; use yield*.
The value the block returns.
An IO that runs the block and produces what it returns.
StaticfromStaticofStaticsequenceTurn an array of IOs into one IO that runs them in order and produces
their results as an array. An empty array gives [].
Nothing runs until run(), and every run() runs every item again, in
order. The array is copied when the IO is built. A throw from an item is
thrown from run(), and the items after it don't run.
This is Haskell's sequence (Data.Traversable). A tuple gives a tuple:
[IO<number>, IO<string>] gives IO<[number, string]>, with no
as const. An array gives an array.
The array or tuple of IOs.
The IOs, in order.
An IO that produces the results in input order (a tuple for a
tuple).
StatictraverseAn IO that applies f to each item in order, runs the IO it returns,
and produces the results as one array. An empty array gives [].
Nothing runs, and f is not called, until run(); every run() runs
every item again, in order. The array is copied when the IO is built,
so changing it afterwards doesn't change what run() does. A throw from
f or from an item is thrown from run(), and the items after it don't
run.
This is Haskell's traverse (also mapM). Like Array#map, f also
gets the item's index.
The item type.
The value type of the IO f returns.
An IO that produces every result in input order.
A synchronous side effect that has not run yet.
Building and composing an
IOperforms nothing, so effects stay referentially transparent until.run()is invoked, once, at the edge of the program.A throw in an effect or a caller-supplied function is thrown from
run(), not from the call that built the IO.Example