From 95a7471db17604a774518930ab7843b1e0f3a0ac Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Tue, 19 May 2020 21:08:13 +0100 Subject: Try! --- src/gleam/dynamic.gleam | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam index 3778a47..6b54df1 100644 --- a/src/gleam/dynamic.gleam +++ b/src/gleam/dynamic.gleam @@ -231,22 +231,10 @@ pub fn tuple2_of( first decode_first: Decoder(a), second decode_second: Decoder(b), ) -> Result(tuple(a, b), String) { - tup - |> tuple2 - |> result.then( - fn(tup) { - let tuple(first, second) = tup - decode_first(first) - |> result.map(fn(first) { tuple(first, second) }) - }, - ) - |> result.then( - fn(tup) { - let tuple(first, second) = tup - decode_second(second) - |> result.map(fn(second) { tuple(first, second) }) - }, - ) + try tuple(first, second) = tuple2(tup) + try a = decode_first(first) + try b = decode_second(second) + Ok(tuple(a, b)) } /// Check to see if the Dynamic value is map. -- cgit v1.2.3