diff options
Diffstat (limited to 'src/result.gleam')
-rw-r--r-- | src/result.gleam | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/result.gleam b/src/result.gleam index 18503ec..a2bd330 100644 --- a/src/result.gleam +++ b/src/result.gleam @@ -91,12 +91,8 @@ test flatten { pub fn then(result, fun) { case result { - | Ok(x) -> - case fun(x) { - | Ok(y) -> Ok(y) - | Error(y) -> Error(y) - } - | Error(_) -> result + | Ok(x) -> fun(x) + | Error(e) -> Error(e) } } @@ -110,6 +106,10 @@ test then { |> expect:equal(_, Ok(2)) Ok(1) + |> then(_, fn(_) { Ok("type change") }) + |> expect:equal(_, Ok("type change")) + + Ok(1) |> then(_, fn(_) { Error(1) }) |> expect:equal(_, Error(1)) } |