/** * This method iterates over the items in the either, yielding each item to the * procedure function. * * @access public * @final * @param callable $procedure the procedure function to be used * @return IEither\Projection the projection */ public final function each(callable $procedure) : IEither\Projection { if ($this->either->__isLeft()) { IUnit\Type::covariant($procedure($this->either->item(), IInt32\Type::zero())); } return $this; }
/** * This method tests the "covariant" method. */ public function test_covariant() { $p0 = IUnit\Type::covariant(IUnit\Type::instance()); $this->assertInstanceOf('\\Saber\\Data\\IUnit\\Type', $p0); $this->assertNull($p0->unbox()); $p1 = IUnit\Type::covariant(null); $this->assertInstanceOf('\\Saber\\Data\\IUnit\\Type', $p1); $this->assertNull($p1->unbox()); }
/** * This method iterates over the items in the option, yielding each item to the * procedure function. * * @access public * @static * @param IOption\Type $xs the left operand * @param callable $procedure the procedure function to be used * @return IOption\Type the option */ public static function each(IOption\Type $xs, callable $procedure) : IOption\Type { if ($xs->__isDefined()) { IUnit\Type::covariant($procedure($xs->item(), IInt32\Type::zero())); } return $xs; }
/** * 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); }
/** * This method iterates over the items in the string, yielding each item to the procedure * function. * * @access public * @static * @param IString\Type $xs the left operand * @param callable $procedure the procedure function to be used * @return IString\Type the string */ public static function each(IString\Type $xs, callable $procedure) : IString\Type { $xi = IString\Module::iterator($xs); foreach ($xi as $i => $x) { IUnit\Type::covariant($procedure($x, $i)); } return $xs; }