コード例 #1
0
ファイル: Type.php プロジェクト: bluesnowman/fphp-saber
 /**
  * This method returns a "cons" object for a choice.
  *
  * @access public
  * @static
  * @param Core\Equality\Type $x                             the object to be evaluated
  * @param Control\Choice\Type $xs                           the tail
  * @return Control\Choice\Type                              the "cons" object
  */
 public static function cons(Core\Equality\Type $x, Control\Choice\Type $xs) : Control\Choice\Type
 {
     if ($xs !== null) {
         return new Control\Choice\Cons\Type($x, $xs);
     }
     return new Control\Choice\Cons\Type($x, Control\Choice\Type::nil());
 }
コード例 #2
0
ファイル: Type.php プロジェクト: bluesnowman/fphp-saber
 /**
  * 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());
 }