Skip to content

Commit f9bc1c0

Browse files
committed
Using return values -debug code
1 parent 5bc5c45 commit f9bc1c0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/functional/monads.p6

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use v6;
77
# Perl 6: { a }
88

99
# return :: (Monad m) => a -> m a
10-
sub mreturn($a) { return { $a } }
10+
sub mreturn($a --> Code ) { return { $a } }
1111

1212
# (>>=) :: (Monad m) => m a -> (a -> m b) -> m b
1313
sub mbind(
14-
Code $ma, # m a
15-
Code $f # (a -> m b)
16-
--> Code
14+
Code $ma, # m a
15+
Code $f # (a -> m b)
16+
--> Code
1717
) {
1818
return {
1919
my $a = $ma(); # Run m a, yielding a
@@ -100,7 +100,6 @@ sub putStrLn(Str $x) { return { say $x; Nil } }
100100
my $results = sequence(@actions);
101101

102102
my $echo_prefixed = mbind($results, -> @results {
103-
say @results;
104103
mapM(-> Str $x { putStrLn($x) }, @results);
105104
});
106105
$echo_prefixed();

0 commit comments

Comments
 (0)