Monadic algorithms.
More...
|
| concept | gimo::applicable_to |
| | Evaluates whether a Nullable type is compatible with the specific Algorithm.
|
| |
|
| template<typename Action> |
| constexpr auto | gimo::and_then (Action &&action) |
| | Creates a pipeline step that applies a function returning a nullable type.
|
| |
| template<typename Action> |
| constexpr auto | gimo::or_else (Action &&action) |
| | Creates a pipeline step that handles the null/error case.
|
| |
| template<typename Action> |
| constexpr auto | gimo::transform (Action &&action) |
| | Creates a pipeline step that transforms the underlying value.
|
| |
| template<typename Action> |
| constexpr auto | gimo::transform_error (Action &&action) |
| | Creates a pipeline step that transforms the error of an expected-like type.
|
| |
Monadic algorithms.
◆ and_then()
template<typename Action>
| auto gimo::and_then |
( |
Action && | action | ) |
|
|
nodiscardconstexpr |
Creates a pipeline step that applies a function returning a nullable type.
- Template Parameters
-
- Parameters
-
- Returns
- A Pipeline step containing the
and_then algorithm.
- On Value: Invokes the
action with the underlying value of the input. The action must return a nullable type.
- On Null: Propagates the null (or error) state immediately (i.e.,
action is not executed).
Let T be the (possibly cv-qualified) reference to the value extracted from the input nullable. Action must be invocable with an argument of type T (or a type to which T is implicitly convertible), while the decayed return-type will become the resulting nullable-type.
- See also
- https://en.wikipedia.org/wiki/Monad_(functional_programming)
◆ or_else()
template<typename Action>
| auto gimo::or_else |
( |
Action && | action | ) |
|
|
nodiscardconstexpr |
Creates a pipeline step that handles the null/error case.
- Template Parameters
-
- Parameters
-
| action | A nullary operation. |
- Returns
- A Pipeline step containing the
or_else algorithm.
◆ transform()
template<typename Action>
| auto gimo::transform |
( |
Action && | action | ) |
|
|
nodiscardconstexpr |
Creates a pipeline step that transforms the underlying value.
- Template Parameters
-
- Parameters
-
- Returns
- A Pipeline step containing the
transform algorithm.
- On Value: Invokes the
action with the underlying value of the input. The result of this invocation is wrapped into a new instance of the nullable container.
- On Null: Propagates the null (or error) state immediately (i.e.,
action is not executed).
Let T be the (possibly cv-qualified) reference to the value extracted from the input nullable. Action must be invocable with an argument of type T (or a type to which T is implicitly convertible), while the decayed return-type will become the value-type of the resulting nullable.
- See also
- https://en.wikipedia.org/wiki/Map_(higher-order_function)
- Note
- The
nullable type must support value-type rebinding.
- See also
- gimo::traits::rebind_value
◆ transform_error()
template<typename Action>
| auto gimo::transform_error |
( |
Action && | action | ) |
|
|
nodiscardconstexpr |
Creates a pipeline step that transforms the error of an expected-like type.
- Template Parameters
-
- Parameters
-
| action | A nullary operation. |
- Returns
- A Pipeline step containing the
or_else algorithm.
- On Value: Propagates the value state immediately (i.e.,
action is not executed).
- On Null: Invokes the
action with the underlying error of the input. The result of this invocation is wrapped as an error into a new instance of the expected_like container.
Let T be the (possibly cv-qualified) reference to the error extracted from the input expected_like. Action must be invocable with an argument of type T (or a type to which T is implicitly convertible), while the decayed return-type will become the error-type of the resulting nullable.
- See also
- https://en.wikipedia.org/wiki/Monad_(functional_programming)
- Note
- The
expected_like type must support error-type rebinding.
- See also
- gimo::traits::rebind_error