Effects#

Effect builders let a generator-based or asynchronous workflow stop as soon as an Option is absent or a Result is an error. Prefer ordinary map and bind for short workflows; see Use effect builders for an example.

A collection of computational expression effects.

async_option#

alias of AsyncOptionBuilder

async_result#

alias of AsyncResultBuilder

async_try#

alias of AsyncTryBuilder

option#

alias of OptionBuilder

result#

alias of ResultBuilder

seq#

alias of SeqBuilder

try_#

alias of TryBuilder

class Builder#

Effect builder.

bind(xs: _M, fn: Callable[[_T], _M]) → _M#
combine(xs: _M, ys: _M) → _M#

Used for combining multiple statements in the effect.

delay(fn: Callable[[], _M]) → _M#

Delay the computation.

Default implementation is to return the result of the function.

return_(x: _T) → _M#
return_from(xs: _M) → _M#
run(computation: _M) → _M#

Run a computation.

Default implementation is to return the computation as is.

zero() → _M#

Zero effect.

Called if the effect raises StopIteration without a value, i.e returns None.

class BuilderState#

Encapsulates the state of a builder computation.