#### Echo program
Example Free Monad example of `echo program` can be found here:
-- See source code [FreeMonadTest.php](/example/FreeMonadTest.php) - example based on first implementation of Free
- See source code [Free2MonadTest.php](/example/Free2MonadTest.php) - example based on second implementation of Free, based on [Haskell implementation](https://hackage.haskell.org/package/free-4.12.4/docs/Control-Monad-Free-Class.html)
#### DSL for `BDD` tests
"files": [
"src/Functional/functions.php",
"src/Functional/miscellaneous.php",
+ "src/Functional/listt.php",
"src/Functional/predicates.php",
"src/Functional/strings.php",
"src/Functional/monoid.php",
"src/Monad/Control/functions.php",
"src/Monad/Either/functions.php",
"src/Monad/Maybe/functions.php",
- "src/Monad/Free/functions.php",
"src/Monad/Free2/functions.php",
"src/Monad/IO/functions.php",
"src/Monad/IO/errors.php",
+++ /dev/null
-<?php
-
-namespace test\Monad;
-
-use Widmogrod\FantasyLand\Functor;
-use Widmogrod\Helpful\FunctorLaws;
-use Widmogrod\Helpful\MonadLaws;
-use function Widmogrod\Monad\Free\liftF;
-use Widmogrod\Monad\Free\MonadFree;
-use Widmogrod\Monad\Free\Pure;
-use const Widmogrod\Functional\identity;
-use Widmogrod\Monad\Identity;
-
-class FreeTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @dataProvider provideFunctorTestData
- */
- public function test_it_should_obey_functor_laws(
- callable $f,
- callable $g,
- Functor $x
- ) {
- FunctorLaws::test(
- function (MonadFree $a, MonadFree $b, $message) {
- $this->assertEquals(
- $a->runFree(identity),
- $b->runFree(identity),
- $message
- );
- },
- $f,
- $g,
- $x
- );
- }
-
- public function provideFunctorTestData()
- {
- return [
- 'Pure' => [
- '$f' => function ($x) {
- return $x + 1;
- },
- '$g' => function ($x) {
- return $x + 5;
- },
- '$x' => Pure::of(1),
- ],
- 'Free' => [
- '$f' => function ($x) {
- return $x + 1;
- },
- '$g' => function ($x) {
- return $x + 5;
- },
- '$x' => liftF(Identity::of(1)),
- ],
- ];
- }
-
- /**
- * @dataProvider provideMonadTestData
- */
- public function test_it_should_obey_monad_laws($f, $g, $x)
- {
- MonadLaws::test(
- function (MonadFree $f, MonadFree $g, $message) {
- $this->assertEquals(
- $f->runFree(identity),
- $g->runFree(identity),
- $message
- );
- },
- function ($x) {
- return Pure::of($x);
- },
- $f,
- $g,
- $x
- );
- }
-
- public function provideMonadTestData()
- {
- $addOne = function ($x) {
- return liftF(Identity::of(
- $x + 1
- ));
- };
- $addTwo = function ($x) {
- return liftF(Identity::of(
- $x + 2
- ));
- };
-
- return [
- 'Identity' => [
- '$f' => $addOne,
- '$g' => $addTwo,
- '$x' => 10,
- ],
- ];
- }
-}