mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
resolve review comments
This commit is contained in:
parent
45f18bd64e
commit
6bae15c467
2 changed files with 42 additions and 5 deletions
|
|
@ -81,11 +81,12 @@ mapErr = \result, transform ->
|
|||
## Maps both the `Ok` and `Err` values of a `Result` to new values.
|
||||
mapBoth : Result ok1 err1, (ok1 -> ok2), (err1 -> err2) -> Result ok2 err2
|
||||
mapBoth = \result, okTransform, errTransform ->
|
||||
result
|
||||
|> Result.map okTransform
|
||||
|> Result.mapErr errTransform
|
||||
when result is
|
||||
Ok val -> Ok (okTransform val)
|
||||
Err err -> Err (errTransform err)
|
||||
|
||||
## Maps the `Ok` values of two `Result`s to a new value using a given transformation.
|
||||
## Maps the `Ok` values of two `Result`s to a new value using a given transformation,
|
||||
## or returns the first `Err` value encountered.
|
||||
map2 : Result a err, Result b err, (a, b -> c) -> Result c err
|
||||
map2 = \firstResult, secondResult, transform ->
|
||||
when (firstResult, secondResult) is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue