short library

Mallard under shorter names: Res, ok, err and friends.

Built from extension types at no runtime cost. Copy it as a template to name the API your own way.

Classes

Absent<T>
A Maybe without a value.
Failure<S, F>
A Result holding the reason an operation failed.
Mallard
Global callbacks that observe every Task and ResultStream outcome, for logging, analytics or crash reporting.
Maybe<T>
A value that is Present or Absent.
Nothing
The success value of an operation that only has an effect, as in Task<Nothing, F>.
Present<T>
A Maybe holding a value, which may itself be null.
Success<S, F>
A Result holding the value an operation produced.

Extension Types

Res
The outcome of an operation that can fail: a Success or a Failure.
ResStream
A deferred source that emits a sequence of Results each time it is run.
Task
A deferred operation that produces a Result each time it is run.

Constants

nothing → const Nothing
The success value of an operation that only has an effect, as in Task<Nothing, F>.

Functions

absent<T>() → Maybe<T>
Returns an Absent.
maybe<T>(T? value) → Maybe<T>
Returns Absent for null, otherwise Present. Shorthand for Maybe.from.
present<T>(T value) → Maybe<T>
Returns a Present holding value.