Module tql_either

Data Types

either()

either(Term, Error) = {ok, Term} | {error, Error}

Function Index

fold/2Fold over a term with a list of functions.
from_bool/3Convert a boolean to the form {ok, Term} or {error, Error}.
is_error/1Check whether the given result tuple is of the form {error, E}.
is_ok/1Check whether the given result tuple is of the form {ok, V}.
sequence/1Combine a list of result tuples.

Function Details

fold/2

fold(Init::term(), Fs::[fun((Term) -> Return)]) -> either(Term, Error)

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(NewValue, Error) or a bare NewValue. If the produced value is an {ok, NewValue} tuple, the next function is called with NewValue as its input. If the produced value is a bare NewValue, the next function is called with that value as its input. If the produced value is an error, processing stops and returns that {error, E} 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(Term, Error, X3::boolean()) -> either(Term, Error)

Convert a boolean to the form {ok, Term} or {error, Error}.

is_error/1

is_error(X1::either(Term, Error)) -> boolean()

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

is_ok/1

is_ok(X1::either(Term, Error)) -> boolean()

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

sequence/1

sequence(Eithers::[either(Term, Error)]) -> either([Term], Error)

Combine a list of result tuples.

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


Generated by EDoc