Esempio n. 1
0
 public final function map(FunctionValue $transformation)
 {
     return $this->wrap(V::fn(function ($collector, $inp) use($transformation) {
         $res = $collector->collect($inp)->force();
         if ($res->isError()) {
             return $res;
         }
         $res2 = $transformation->apply($res)->force();
         // If mapping was successfull, the underlying value should
         // be considered the origin of the produced value.
         if (!$res2->isError() && !$res2->isApplicable()) {
             return V::val($res2->get(), $res->origin());
         }
         return $res2;
     }));
 }
Esempio n. 2
0
 public function composeWith(FunctionValue $other)
 {
     return V::fn_w(function ($value) use($other) {
         $res = $other->apply($value)->force();
         return $this->apply($res)->force();
     });
 }