traverseResult
Last updated
Last updated
Namespace: FsToolkit.ErrorHandling
Function Signature:
Note that traverse
is the same as map >> sequence
. See also .
See also Scott Wlaschin's .
If we have a value of type string option
and want to call the tryParseInt
function that we defined in the , we can achieve it using the traverseResult
function as below:
Let's assume that we have this function to convert a LocationDto
to a Location
:
Then in order to create a similar function to convert a CreatePostRequestDto
to a CreatePostRequest
, we can make use of traverseResult
as below:
The CreatePostRequest
type that we defined in contains a Location option
. The corresponding DTO objects would look like this:
See also the of ResultOption.map2.