### List Functor
```php
use Widmogrod\Functional as f;
-use Widmogrod\Primitive\Listt;
$list = f\fromIterable([
['id' => 1, 'name' => 'One'],
```php
use Widmogrod\Functional as f;
-use Widmogrod\Primitive\Listt;
$listA = f\fromIterable([
function($a) {
By combining List and Maybe Monad, this process becomes simpler and more readable.
```php
+use Widmogrod\Functional as f;
use Widmogrod\Monad\Maybe;
-use Widmogrod\Primitive\Listt;
$data = [
['id' => 1, 'meta' => ['images' => ['//first.jpg', '//second.jpg']]],
['id' => 3],
];
-// $get :: String a -> Maybe [b] -> Maybe b
+// $get :: String a -> Maybe [b] -> [Maybe b]
$get = function ($key) {
return f\bind(function ($array) use ($key) {
- return isset($array[$key])
- ? Maybe\just($array[$key])
- : Maybe\nothing();
+ return f\fromValue(
+ isset($array[$key])
+ ? Maybe\just($array[$key])
+ : Maybe\nothing()
+ );
});
};