module documentation

General functional-style helpers for disttrial.

Function compose Create a function that calls one function with an argument and then another function with the result of the first function.
Function countingCalls Wrap a function with another that automatically passes an integer counter of the number of calls that have gone through the wrapper.
Function flip Create a function like another but with the order of the first two arguments flipped.
Function fromOptional Get a definite value from an optional value.
Async Function iterateWhile Call a function repeatedly until its result fails to satisfy a predicate.
Async Function sequence Wait for one action to complete and then another.
Function takeWhile :return: An iterable over C{xs} that stops when C{condition} returns ``False`` based on the value of iterated C{xs}.
Variable discardResult Undocumented
Type Variable _A Undocumented
Type Variable _B Undocumented
Type Variable _C Undocumented
def compose(fx: Callable[[_B], _C], fy: Callable[[_A], _B]) -> Callable[[_A], _C]: (source)

Create a function that calls one function with an argument and then another function with the result of the first function.

def countingCalls(f: Callable[[int], _A]) -> Callable[[], _A]: (source)

Wrap a function with another that automatically passes an integer counter of the number of calls that have gone through the wrapper.

def flip(f: Callable[[_A, _B], _C]) -> Callable[[_B, _A], _C]: (source)

Create a function like another but with the order of the first two arguments flipped.

def fromOptional(default: _A, optional: Optional[_A]) -> _A: (source)

Get a definite value from an optional value.

Parameters
default:_AThe value to return if the optional value is missing.
optional:Optional[_A]The optional value to return if it exists.
Returns
_AUndocumented
async def iterateWhile(predicate: Callable[[_A], bool], action: Callable[[], Awaitable[_A]]) -> _A: (source)

Call a function repeatedly until its result fails to satisfy a predicate.

Parameters
predicate:Callable[[_A], bool]The check to apply.
action:Callable[[], Awaitable[_A]]The function to call.
Returns
_AThe result of action which did not satisfy predicate.
async def sequence(a: Awaitable[_A], b: Awaitable[_B]) -> _B: (source)

Wait for one action to complete and then another.

If either action fails, failure is propagated. If the first action fails, the second action is not waited on.

def takeWhile(condition: Callable[[_A], bool], xs: Iterable[_A]) -> Iterable[_A]: (source)

:return: An iterable over C{xs} that stops when C{condition} returns ``False`` based on the value of iterated C{xs}.

Undocumented

Undocumented

Value
TypeVar('_A')

Undocumented

Value
TypeVar('_B')

Undocumented

Value
TypeVar('_C')