Esempio n. 1
0
 /**
  * This method sets the procedure that will be executed should "y" equal "x".
  *
  * @access public
  * @final
  * @param Core\Equality\Type $y                             the object to be evaluated
  *                                                          against
  * @param callable $procedure                               the procedure to be executed
  * @return Control\Choice\Type                              a reference to the next choice
  *                                                          monad node
  */
 public final function when(Core\Equality\Type $y, callable $procedure) : Control\Choice\Type
 {
     $this->predicate = function ($x) use($y, $procedure) {
         if ($y->__eq($x)) {
             IUnit\Type::covariant($procedure($x));
             return true;
         }
         return false;
     };
     return Control\Choice\Type::cons($this->x, $this);
 }
Esempio n. 2
0
 /**
  * This method returns a choice monad for evaluating an object.
  *
  * @access public
  * @static
  * @param Core\Equality\Type $x                             the object to be evaluated
  * @return Control\Choice\Type                              the choice monad
  */
 public static function choice(Core\Equality\Type $x) : Control\Choice\Type
 {
     return Control\Choice\Type::cons($x, Control\Choice\Type::nil());
 }