apply
Namespace: FsToolkit.ErrorHandling
apply
combines two Result values and returns a new Result value. If both Result values are Ok, it applies the function from the first Result to the value from the second Result, producing a new Result type. If either Result is an Error, the apply function propagates the error by returning the corresponding Error value.
Function Signature
Examples
Example 1
Note: The apply
function is most useful in its infix operator form <*>
when using it over a multi-parameter function. Examples of this is shown in the documentation for this operator. The example below is a bit artificial since map
is arguably better.
Assume that we have a function to find the remaining characters of a Tweet:
If we want a function that takes a plain string instead, we can achieve it using the apply
function:
But as mentioned, using the map
function is simpler in this case:
Last updated