Module tql_either

Data Types

either()

either(Result, Reason) = {ok, Result} | {error, Reason}

Function Index

and_/1Fold over a term that depend on a previous result.
fold/2Fold over a term with a list of functions.
from_bool/3Convert a boolean to the form {ok, Result} or {error, Reason}.
is_error/1Check whether the given result tuple is of the form {error, Reason}.
is_ok/1Check whether the given result tuple is of the form {ok, Result}.
oks/1Collect the ok values from a list of result tuples.
sequence/1Combine a list of result tuples.
with_default/2

Function Details

and_/1

and_(F::fun((X) -> either(Y, Err))) -> fun((X) -> either({X, Y}, Err))

Fold over a term that depend on a previous result

fold/2

fold(Init::term(), Fs::[fun((Result) -> Return)]) -> either(Result, Reason)

Fold over a term with a list of functions.

The first function in the list is called with the initial value, and expected to produce either an either(Result, Reason) or a bare Result. If the produced value is an {ok, Result} tuple, the next function is called with Result as its input. If the produced value is a bare Result, the next function is called with that value as its input. If the produced value is an error, processing stops and returns that {error, Reason} tuple.

Note that this function will always produce a tuple, so if the final function produces a bare value, this will be wrapped in a tuple, too.

from_bool/3

from_bool(Result, Reason, X3::boolean()) -> either(Result, Reason)

Convert a boolean to the form {ok, Result} or {error, Reason}.

is_error/1

is_error(X1::either(Result, Reason)) -> boolean()

Check whether the given result tuple is of the form {error, Reason}.

is_ok/1

is_ok(X1::either(Result, Reason)) -> boolean()

Check whether the given result tuple is of the form {ok, Result}.

oks/1

oks(Eithers::[either(Result, Reason)]) -> [Result]

Collect the ok values from a list of result tuples.

sequence/1

sequence(Eithers::[either(Result, Reason)]) -> either([Result], Reason)

Combine a list of result tuples.

This will result in either an {error, Reason} if any of the supplied tuples is an error, or {ok, [Result]} with all the ok-values sequenced into a list.

with_default/2

with_default(X1::either(Result, Reason), Default) -> Result | Default


Generated by EDoc