resolve review comments

This commit is contained in:
Luke Boswell 2024-08-14 17:24:12 +10:00
parent 45f18bd64e
commit 6bae15c467
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 42 additions and 5 deletions

View file

@ -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