File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace example ;
6
6
7
+ use Widmogrod \Monad \Identity ;
7
8
use function Widmogrod \Monad \Control \Doo \doo ;
8
9
use function Widmogrod \Monad \Control \Doo \in ;
9
10
use function Widmogrod \Monad \Control \Doo \let ;
10
- use Widmogrod \Monad \Identity ;
11
11
12
12
class FreeDooDSLTest extends \PHPUnit \Framework \TestCase
13
13
{
14
- public function test_it ()
14
+ public function test_example_with_do_notation ()
15
15
{
16
16
$ result = doo (
17
17
let ('a ' , Identity::of (1 )),
@@ -26,4 +26,21 @@ public function test_it()
26
26
27
27
$ this ->assertEquals (Identity::of (16 ), $ result );
28
28
}
29
+
30
+ public function test_example_without_do_notation ()
31
+ {
32
+ $ result = Identity::of (1 )
33
+ ->bind (function ($ a ) {
34
+ return Identity::of (3 )
35
+ ->bind (function ($ b ) use ($ a ) {
36
+ return Identity::of ($ a + $ b )
37
+ ->bind (function ($ c ) {
38
+ return Identity::of ($ c * $ c );
39
+ });
40
+ });
41
+
42
+ });
43
+
44
+ $ this ->assertEquals (Identity::of (16 ), $ result );
45
+ }
29
46
}
You can’t perform that action at this time.
0 commit comments