public function provideFunctorTestData() { return ['State' => ['$f' => function ($x) { return $x + 1; }, '$g' => function ($x) { return $x + 5; }, '$x' => State\value(3), '$state' => 'asd']]; }
function searchRelated($productName) { // TODO: 1. try use doM // TODO: 2. try implement getOrElse return checkRelatedInCache($productName)->bind(function (Maybe\Maybe $products) use($productName) { switch (get_class($products)) { case Maybe\Just::class: return S\value($products->extract()); case Maybe\Nothing::class: return retrieveRelated($productName); } }); }