aboutsummaryrefslogtreecommitdiff
path: root/src/result.gleam
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-03-17 22:12:37 +0000
committerLouis Pilfold <louis@lpil.uk>2019-03-17 22:12:37 +0000
commit0f0f3df21b71678504cd8c0fb0e55dfd7af5f176 (patch)
tree4a470d96b115cd2c12389523462d271db391894d /src/result.gleam
parentfbd570295cd40802127913d2b308916eefb14066 (diff)
downloadgleam_stdlib-0f0f3df21b71678504cd8c0fb0e55dfd7af5f176.tar.gz
gleam_stdlib-0f0f3df21b71678504cd8c0fb0e55dfd7af5f176.zip
Unify tuple patterns with type vars
Diffstat (limited to 'src/result.gleam')
-rw-r--r--src/result.gleam12
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))
}