/**
  * Check weather application operator works as expected: f $ x = f x
  * @dataProvider compose_functions
  **/
 public function testApplicationOperator($fn, $fn2, $value)
 {
     $fn = $fn->composeWith($fn2);
     $res1 = $fn->apply($value);
     $res2 = V::application_to($value)->apply($fn);
     $this->assertEquals($res1->get(), $res2->get());
 }
 /**
  * Tests third applicative law: u <*> pure y = pure ($ y) <*> u
  * Applicative can be reversed when function application is reversed
  * two.
  * @dataProvider formlets_and_values
  */
 public function testApplicativeInterchange($formlet, $fn1, $fn2, $value, $contains_applicable)
 {
     if (!$contains_applicable) {
         return;
     }
     $left = $formlet->cmb(F::pure($value));
     $right = F::pure(V::application_to($value))->cmb($formlet);
     $this->assertFormletsEqual($left, $right, $value, false);
 }
示例#3
0
 /**
  * Get the function that applies the given value to another function.
  *
  * @return  IValue
  */
 public static function application_to(IValue $val)
 {
     return V::application_to($val);
 }