Skip to content

Commit 4663603

Browse files
committed
Add static test for sequenceOptionT
1 parent 5f4a74b commit 4663603

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/Static/Plugin/SequenceOptionPluginStaticTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use Fp\Functional\Option\Option;
88

9+
use function Fp\Collection\at;
910
use function Fp\Collection\sequenceOption;
11+
use function Fp\Collection\sequenceOptionT;
1012
use function Fp\Evidence\proveInt;
1113
use function Fp\Evidence\proveString;
1214

@@ -91,4 +93,16 @@ public function sequenceLazyTuple(mixed $name, mixed $age): Option
9193
fn() => proveInt($age),
9294
]);
9395
}
96+
97+
/**
98+
* @param array<string, mixed> $data
99+
* @return Option<array{string, int}>
100+
*/
101+
public function sequenceT(array $data): Option
102+
{
103+
return sequenceOptionT(
104+
at($data, 'name')->flatMap(proveString(...)),
105+
at($data, 'age')->flatMap(proveInt(...)),
106+
);
107+
}
94108
}

0 commit comments

Comments
 (0)