We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 05b4225 commit 5bc5c45Copy full SHA for 5bc5c45
examples/functional/monads.pl renamed to examples/functional/monads.p6
@@ -1,3 +1,7 @@
1
+#!/usr/bin/env perl6
2
+
3
+use v6;
4
5
# Definition:
6
# Haskell: IO a
7
# Perl 6: { a }
@@ -8,9 +12,8 @@
8
12
# (>>=) :: (Monad m) => m a -> (a -> m b) -> m b
9
13
sub mbind(
10
14
Code $ma, # m a
11
- Code $f, # (a -> m b)
- # This should be "Code $f returns Code", but Pugs doesn't
- # grok that yet.
15
+ Code $f # (a -> m b)
16
+ --> Code
17
) {
18
return {
19
my $a = $ma(); # Run m a, yielding a
@@ -96,7 +99,8 @@ ()
96
99
# results :: IO [String]
97
100
my $results = sequence(@actions);
98
101
- my $echo_prefixed = mbind($results, -> *@results {
102
+ my $echo_prefixed = mbind($results, -> @results {
103
+ say @results;
104
mapM(-> Str $x { putStrLn($x) }, @results);
105
});
106
$echo_prefixed();
0 commit comments