map_ok : Result a err, (a -> b) -> Result b err
If the result is Ok, transforms the value it holds by running a conversion
function on it. Then returns a new Ok holding the transformed value. If the
result is Err, this has no effect. Use map_err to transform an Err.
Result.map_ok(Ok(12), Num.neg)
Result.map_ok(Err("yipes!"), Num.neg)Functions like map are common in Roc; see for example List.map,
Set.map, and Dict.map.
map_err : Result ok a, (a -> b) -> Result ok b
If the result is Err, transforms the value it holds by running a conversion
function on it. Then returns a new Err holding the transformed value. If
the result is Ok, this has no effect. Use [map] to transform an Ok.
Result.map_err(Err("yipes!"), Str.is_empty)
Result.map_err(Ok(12), Str.is_empty)try : Result a err, (a -> Result b err) -> Result b err
If the result is Ok, transforms the entire result by running a conversion
function on the value the Ok holds. Then returns that new result. If the
result is Err, this has no effect. Use on_err to transform an Err.
Result.try(Ok(-1), (\num -> if num < 0 then Err("negative!") else Ok(-num)))
Result.try(Err("yipes!"), (\num -> if num < 0 then Err("negative!") else Ok(-num)))on_err : Result a err, (err -> Result a other_err) -> Result a other_err
If the result is Err, transforms the entire result by running a conversion
function on the value the Err holds. Then returns that new result. If the
result is Ok, this has no effect. Use try to transform an Ok.
Result.on_err(Ok(10), (\error_num -> Str.to_u64(error_num)))
Result.on_err(Err("42"), (\error_num -> Str.to_u64(error_num)))