From c27456a39d827306eb45734465676ad4cb39a639 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Wed, 26 Nov 2025 15:19:47 +0000 Subject: [PATCH 1/4] Make error generic in attempt --- src/Result/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Result/functions.php b/src/Result/functions.php index 46cbfb0..84ee083 100644 --- a/src/Result/functions.php +++ b/src/Result/functions.php @@ -30,8 +30,9 @@ function Err(mixed $err): Err /** * @template T + * @template E of Throwable * @param callable(): T $f - * @return Result + * @return Result */ function attempt(callable $f): Result { From 3d799a7641b84788a3f9d31af39185c45b1fb858 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Wed, 26 Nov 2025 15:44:10 +0000 Subject: [PATCH 2/4] wip --- src/Result/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Result/functions.php b/src/Result/functions.php index 84ee083..6b53a21 100644 --- a/src/Result/functions.php +++ b/src/Result/functions.php @@ -31,7 +31,7 @@ function Err(mixed $err): Err /** * @template T * @template E of Throwable - * @param callable(): T $f + * @param callable(): T @throws E $f * @return Result */ function attempt(callable $f): Result From 42d96a8709062a2a9597916f4cc3bd58e8e4e325 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Wed, 26 Nov 2025 15:46:52 +0000 Subject: [PATCH 3/4] wip --- src/Result/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Result/functions.php b/src/Result/functions.php index 6b53a21..4c328d6 100644 --- a/src/Result/functions.php +++ b/src/Result/functions.php @@ -31,7 +31,7 @@ function Err(mixed $err): Err /** * @template T * @template E of Throwable - * @param callable(): T @throws E $f + * @param callable(): T $f * @return Result */ function attempt(callable $f): Result @@ -39,6 +39,7 @@ function attempt(callable $f): Result try { return Ok($f()); } catch (Throwable $e) { + /** @var E $e */ return Err($e); } } From 31c96b223a75c152e4b33a5bfe2425c7749f8873 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Wed, 26 Nov 2025 15:58:10 +0000 Subject: [PATCH 4/4] wip --- src/Result/functions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Result/functions.php b/src/Result/functions.php index 4c328d6..ba6d72b 100644 --- a/src/Result/functions.php +++ b/src/Result/functions.php @@ -32,14 +32,13 @@ function Err(mixed $err): Err * @template T * @template E of Throwable * @param callable(): T $f - * @return Result + * @return Result */ function attempt(callable $f): Result { try { return Ok($f()); } catch (Throwable $e) { - /** @var E $e */ return Err($e); } }