Functional Pearls 4 (YAPC::EU::2009 remix)

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite & 1 Event

    Functional Pearls 4 (YAPC::EU::2009 remix) - Presentation Transcript

    1. osfameron Functional Pe(a)rls
    2. Functional pe(a)rls World tour! IPW 2008 LPW 2008 NWE.pm May 2009 YAPC::EU Lisbon 2009 version 4 Osfameron
    3. Functional Programming What is it?
    4. Functional Programming About functions?
    5. Functional Programming About functions? (like Object-oriented is about objects?)
    6. Functional Programming everything's a function!
    7. Functional Programming 1 + 2
    8. Functional Programming 1 + 2 Spot the function?
    9. Functional Programming 1 + 2 Spot the function?
    10. Functional Programming 1 + 2 first class?
    11. Functional Programming 1 + 2 +
    12. Functional Programming 1 + 2 op<+>
    13. OPERATORS UNITE! STOP this discrimation now!
    14. What now?
      • Protest!
      • Cry!
      • Steal from Haskell!
    15. What now?
      • Steal from Haskell!
      • (+) ← ref to add
    16. Wrapping operators
      • sub op ($op) { return sub ($left, $right) { eval “$left $op $right” ; }; }
    17. Wrapping operators
      • my $add = op('+');
      • $add->(1, 2); # 3
    18. YAY!
    19. YAY?
      • Still uglier than Haskell
        • (+)
        • op('+')
    20. Devel::Declare
      • New syntax!
      • (But better than source filters)
    21. Devel::Declare
      • New syntax!
      • (But better than source filters)
        • Method declaration
        • MooseX::Declare
        • Sub::Auto
    22. Sub::Section
      • on github
      • Gives nice syntax, using Devel::Declare
      • op (+)
    23. Sub::Section
      • on github
      • Gives nice syntax, using Devel::Declare
      • op (Bwahaha!) (+)
      Devel::Declare custom parser hook can inject code etc.
    24. Sub::Section
      • on github
      • Gives nice syntax, using Devel::Declare
      • op (Bwahaha!) ('+')
    25. Sub::Section
      • on github
      • Gives nice syntax, using Devel::Declare
      • Op ('+') # Perl is none the wiser
      Tee hee!
    26. Devel::Declare
      • In Perl!
      • (With a bit of scary XS magic)
        • hooks into the compiler
        • changing the source as you compile
        • horrible perl tricks to get methods installed, and braces closed
        • mst++, rafl++
    27. Sections
    28. Sections
      • (+) isn't really a section
    29. Sections
      • (+) isn't really a section
      • (+1) is
    30. Sections
      • (+) 10, 5 # 15
      • (+1) 8 # 9
    31. Currying
      • Partial application
    32. Currying
      • Partial application
      • 1 arg at a time
    33. Currying
      • sub add ($left, $right) { return $left + $right; }
    34. Currying
      • sub add ($left, $right) { return $left + $right; }
      • (That's 2 arguments)
    35. Curried functions
      • sub add ($left, $right) { return $left + $right; }
      • (That's 2 arguments)
      • add(5) ...
    36. Curried functions
      • sub add ($left, $right) { return $left + $right; }
      • (That's 2 arguments)
      • add(5) # $left is bound to 5
    37. Curried functions
      • sub add ($left, $right) { return $left + $right; }
      • (That's 2 arguments)
      • add(5) # $left is bound to 5 ->(6); # 11
    38. Implement in Perl
      • Quite simple to do with closures:
      • sub add { my $left = shift; return sub { my $right = shift; return $left + $right; } }
    39. Implement in Perl
      • Quite simple to do with closures:
      • sub add { my $left = shift; return sub { my $right = shift; return $left + $right; } }
      • Not pretty or convenient though
    40. Sub::Curried
      • on CPAN
      • Gives nice syntax, using Devel::Declare
      • sub add ($left, $right) { return $left + $right; }
    41. Sub::Curried
      • on CPAN
      • Gives nice syntax, using Devel::Declare
      • curry add ($left, $right) { return $left + $right; }
    42. Sub::Curried
      • on CPAN
      • Gives nice syntax, using Devel::Declare
      • curry (bwahaha!) add ($left, $right) { return $left + $right; }
    43. Sub::Curried
      • Turn into something like
      • curry add { return ROUTINE unless @_; check_args(2, @_); my $f = sub { my $f = sub { ... } $f = $f->(shift) for @_; return $f; }
    44. Sub::Curried
      • Turn into something like
      • curry add { return ROUTINE unless @_ ; check_args(2, @_); my $f = sub { my $f = sub { ... } $f = $f->(shift) for @_; return $f; }
    45. Sub::Curried
      • add(5,6); # 11
    46. Sub::Curried
      • add(5,6); # 11
      • add(5); # function that adds 5
    47. Sub::Curried
      • add(5,6); # 11
      • add(5); # function that adds 5
      • add(); # function that adds...
    48. Sub::Curried
      • add(5,6); # 11
      • add(5); # function that adds 5
      • add(); # function that adds...
      • i.e = &add
    49. Sub::Curried
      • Turn into something like
      • curry add { return ROUTINE unless @_; check_args(2 , @_); my $f = sub { my $f = sub { ... } $f = $f->(shift) for @_; return $f; }
    50. Sub::Curried
      • Give diagnostics if called with too many arguments
    51. Sub::Curried
      • Turn into something like
      • curry add { return ROUTINE unless @_; check_args(2, @_); my $f = sub { my $f = sub { ... } $f = $f->(shift) for @_; return $f; }
    52. Sub::Curried
      • Handle
        • add(1,2)
        • add(1)->(2)
    53. Why?
      • Partial application
    54. Why?
      • Automatic partial application everywhere
    55. Why?
      • Automatic partial application everywhere
      • ... turns out to be useful/elegant in Haskell
    56. Why?
      • Automatic partial application everywhere
      • ... turns out to be useful/elegant in Haskell
      • (actually, similar techniques are used in Perl)
    57. Currying the Invocant
      • package My::Class use base 'Class::Accessor'; __PACKAGE__->add_accessor('foo'); __PACKAGE__->add_accessor('bar'); __PACKAGE__->add_accessor('baz');
    58. Currying the Invocant
      • package My::Class use base 'Class::Accessor'; My::Class ->add_accessor('foo'); My::Class ->add_accessor('bar'); My::Class ->add_accessor('baz');
    59. Currying the Invocant
      • package My::Class use base 'Class::Accessor'; My::Class ->add_accessor('foo'); My::Class ->add_accessor('bar'); My::Class ->add_accessor('baz');
      • sub add_accessor { my ( $self , $accessor) = @_; ....
    60. Currying the Invocant
      • Perl importing
        • *{$CALLER::has} = &has;
    61. Currying the Invocant
      • Perl importing
        • *{$CALLER::has} = &has;
        • *{$CALLER::has} = mk_has();
    62. Currying the Invocant
      • Perl importing
        • *{$CALLER::has} = &has;
        • *{$CALLER::has} = mk_has();
        • *{$CALLER::has} = has($CALLER);
    63. Currying the Invocant
      • Moose!
        • package My::Class; use Moose; # imports has=has('My::Class') has 'foo'; has 'bar'; has 'baz';
    64. Currying the Invocant
      • Moose!
        • package My::Class; use Moose; # imports has=has('My::Class') has 'foo'; has 'bar'; has 'baz';
      • (handwave)
    65. Where were we?
      • my $add = +; # FAIL
    66. Where were we?
      • my $add = +; # FAIL
      • my $add = op(+); # YAY
    67. Where were we?
      • my $add = +; # FAIL
      • my $add = op(+); # YAY
      • my $add2 = op(+2); # take THAT, Haskell!
    68. But...
      • (-1)
    69. But...
      • (-1)
      • (1-)
    70. But...
      • (-1)
      • (1-) # minus(1)
    71. But...
      • (-1) # minus(???)->(1)
      • (1-) # minus(1)
    72. But...
      • (-1) # (flip(minus))->(1)
      • (1-) # minus(1)
    73. Flip
      • curry flip ($fn, $left, $right) { $fn->($right, $left); }
    74. Flip
      • curry flip ($fn, $left, $right ) { $fn->($right, $left); }
      • Minus (3, 1) # 2
      • flip(minus)->(3, 1) # -2;
    75. Flip
      • … and with currying
      • my $prev = flip(minus)->(1);
      • $prev->( 5 );
        • $left = 1
        • $right = 5
        • minus($right=5, $left=1); # 4
    76. Sub::Section
      • More cool stuff
    77. Sub::Section
      • my $greet = op(“Hello ” .);
    78. Sub::Section
      • my $greet = op(“Hello ” .);
      • $greet->(“World”); # “Hello World”
    79. Sub::Section
      • map op(*2), @numbers;
        • (1,2,3,4)
        • > (2,4,6,8)
    80. Sub::Section
      • map op(*2), @numbers;
        • (1,2,3,4)
        • > (2,4,6,8)
    81. Sub::Section
      • Perl map doesn't take functions...
    82. Sub::Section
      • Perl map doesn't take functions...
      • map op(*2) ->($_) , @numbers;
        • (1,2,3,4)
        • > (2,4,6,8)
    83. (rant)
      • Perl's map is not functional
    84. (rant)
      • Perl's map is not functional
        • We took a feature from FP... and made it not take functions.
    85. (rant)
      • Perl's map is not functional
      • Perl's $_ is a horrible hack around not doing currying properly
    86. (rant)
      • Perl's map is not functional
      • Perl's $_ is a horrible hack around not doing currying properly
      • Why am I still programming this silly language? ;-)
    87. (yay!)
      • Perl's map is not functional
      • Perl's $_ is a horrible hack around not doing currying properly
      • Why am I still programming this silly language? ;-)
      • Oh yes! - because I can change it.
    88. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
    89. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
      • (those will all work anyway)
    90. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
      • (those will all work anyway)
      • fmap { uc } @list;
    91. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
      • (those will all work anyway)
      • fmap (bwahahaha!) { uc } @list;
    92. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
      • (those will all work anyway)
      • fmap sub { uc } , @list;
    93. TODO: Functional::Map
      • fmap &some_func, @list;
      • fmap sub { … }, @list;
      • fmap op(+2), @list;
      • (those will all work anyway)
      • fmap underscorify( sub { uc } ) , @list;
    94. TODO: Functional::Map
      • Dear lazyYAPC...
    95. Sub::Section
      • my $contains_foo = op(=~/foo/);
    96. More complex examples
      • centigrade = (fahrenheit-32)*5/9
    97. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = sub { op(*5/9)->( op(-32)->(shift)) };
    98. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = sub { op(*5/9)->( op(-32)->(shift)) };
      • MY EYES!
    99. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = sub { op(*5/9) ->( op(-32) ->(shift)) };
    100. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = sub { op(*5/9) ->( op(-32) ->(shift)) };
      • Never mind the boilerplate...
    101. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = op(*5/9) << op(-32)
      • Composition
    102. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = op(*5/9) << op(-32)
      • Sub::Compose
    103. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = op(*5/9) << op(-32)
      • Sub::Compose
        • base class for Sub::Curried, Sub::Section
    104. More complex examples
      • centigrade = (fahrenheit-32)*5/9
      • my $f2c = op(*5/9) << op(-32)
      • Sub::Compose
        • base class for Sub::Curried, Sub::Section
        • ... autobox?
    105. Point-free!
      • Or point less programming
      • (obfu for maths types)
    106. Point-free!
      • my $square = op(*) << dup;
      • $square->(4); # 16
    107. Point-free!
      • curry dup ($arg) { ($arg)x 2 }
      • my $square = op(*) << dup;
      • $square->(4); # 16
    108. Point-free!
      • curry dup ($arg) { ($arg)x 2 }
      • my $dup = op(x 2); # ?
    109. Point-free!
      • curry dup ($arg) { ($arg)x 2 }
      • my $dup = op(x 2); “$arg$arg”
    110. Point-free!
      • curry dup ($arg) { ($arg)x 2 }
      • my $dup = op(x 2); “$arg$arg”
        • TODO: alternate syntax for list context:
        • op[x 2] # thanks mst
    111. Some light relief
    112. Some light relief Monads
    113. Monads
      • Come from maths
      • “Category theory”
    114. Monads
      • Come from maths
      • “Category theory”
      • Very clever people rave about them being useful
    115. Monads
      • Come from maths
      • “Category theory”
      • Very clever people rave about them being useful
      • Have a reputation for being hard to understand
    116. Monad tutorials
    117. Monad tutorials
    118. Monad tutorials
    119. Monad tutorials
    120. Monad tutorials Step 1: Write Monad Tutorial
    121. Monad tutorials Step 2: ???
    122. Monad tutorials Step 3: Profit!
    123. Monads
      • You already use monads
    124. Monads
      • You already use monads
      • YAY!
    125. Monads
      • You already use monads
      • Sequences of commands?
    126. Sequencing my $x = 1; my $y = 2; my $z = $x * $y; say “$x * $y = $z”;
    127. Sequencing my $x = 1; my $y = 2; my $z = $x * $y; say “$x * $y = $z”;
    128. Sequencing my $x = 1; my $y = 2; my $z = $x * $y; say “$x * $y = $z”;
    129. Sequencing my @seq = sub { my $x = 1 }, sub { my $y = 2 }, sub { my $z = $x * $y }, sub { say &quot;$x * $y = $z&quot; };
    130. Sequencing my @seq = sub { my $x = 1 }, sub { my $y = 2 }, sub { my $z = $x * $y }, sub { say &quot;$x * $y = $z&quot; }; # Global symbol &quot;$x&quot; requires explicit package name at ...
    131. Nesting my $x = 1; my $y = 2; my $z = $x * $y; say “$x * $y = $z”;
    132. Nesting sub { my $x = 1; sub { my $y = 2; sub { my $z = $x * $y; sub { say &quot;$x * $y = $z&quot;; }->() }->() }->() }->();
    133. Monadic programming is impractical in Perl... only because of syntactic issues – Mark Jason Dominus http://perl.plover.com/classes/fp/samples/slide027.html
    134. Monads made pretty
      • Source filters!
        • http://sleepingsquirrel.org/monads/monads.html
    135. Monads made pretty
      • Source filters!
        • http://sleepingsquirrel.org/monads/monads.html
      • Source tree manipulation (B::OP magic)
      • Deparse and source text munging
    136. Monads made pretty
      • We want a syntax like
      • mdo { my $x = mbind(1); my $y = mbind(2); my $z = mbind($x + $y); say “$x * $y = $z”; }
    137. Monads made pretty
      • We want a syntax like
      • mdo { my $x = mbind(1); my $y = mbind(2); my $z = mbind($x + $y); say “$x * $y = $z”; }
      • mdo introduces the block
      • mbind gives us a hook to rotate around
    138. Optree munging
      • 19: my $x << Just 2; ... n <;> nextstate(main 2078 b.pl:19) v:*,&,$ ->o t <2> left_shift[t3] vK ->u o <0> padsv[$x:2078,2080] sM/LVINTRO ->p s <1> entersub[t2] sKS/TARG,3 ->t - <1> ex-list sK ->s p <0> pushmark s ->q q <$> const(IV 2) sM ->r - <1> ex-rv2cv sK/130 ->- r <$> gv(*Just) s ->s u <;> nextstate(main 2079 b.pl:20) v:*,&,$ ->v
      • # : mbind (Just 2), sub { my $x = shift; ... }; <;> nextstate(main b.pl:) v:*,&,{,$ -> <@> list K -> <0> pushmark s -> <1> entersub[t2] KS/TARG,3 -> - <1> ex-list K -> <0> pushmark s -> <1> entersub[t1] lKMS/NO(),TARG,INARGS,3 -> - <1> ex-list lK -> <0> pushmark s -> <$> const(IV 2) sM -> - <1> ex-rv2cv sK/130 ->- <$> gv(*Just) s -> - <1> ex-rv2cv sK/2 ->- # mbind instead of >> <$> gv(*mbind) s -> <1> refgen K/1 -> - <1> ex-list lKRM -> <0> pushmark sRM -> <$> anoncode[CV ] lRM -> # ??? set up anon sub # my $x = shift <0> padsv[$x:2078,2080] sM/LVINTRO ->p # the next ; is moved into this new lambda! <;> nextstate(main 2079 b.pl:20) v:*,&,$ ->v
    139. Optree munging
      • 19: my $x << Just 2; ... n <;> nextstate(main 2078 b.pl:19) v:*,&,$ ->o t <2> left_shift[t3] vK ->u o <0> padsv[$x:2078,2080] sM/LVINTRO ->p s <1> entersub[t2] sKS/TARG,3 ->t - <1> ex-list sK ->s p <0> pushmark s ->q q <$> const(IV 2) sM ->r - <1> ex-rv2cv sK/130 ->- r <$> gv(*Just) s ->s u <;> nextstate(main 2079 b.pl:20) v:*,&,$ ->v
      • # : mbind (Just 2), sub { my $x = shift; ... }; <;> nextstate(main b.pl:) v:*,&,{,$ -> <@> list K -> <0> pushmark s -> <1> entersub[t2] KS/TARG,3 -> - <1> ex-list K -> <0> pushmark s -> <1> entersub[t1] lKMS/NO(),TARG,INARGS,3 -> - <1> ex-list lK -> <0> pushmark s -> <$> const(IV 2) sM -> - <1> ex-rv2cv sK/130 ->- <$> gv(*Just) s -> - <1> ex-rv2cv sK/2 ->- # mbind instead of >> <$> gv(*mbind) s -> <1> refgen K/1 -> - <1> ex-list lKRM -> <0> pushmark sRM -> <$> anoncode[CV ] lRM -> # ??? set up anon sub # my $x = shift <0> padsv[$x:2078,2080] sM/LVINTRO ->p # the next ; is moved into this new lambda! <;> nextstate(main 2079 b.pl:20) v:*,&,$ ->v
      KABOOM
    140. Source deparsing
      • Works surprisingly well
    141. Source deparsing
      • Works surprisingly well
      • for trivial cases
      • (a bit fragile)
    142. Source deparsing
      • Works surprisingly well
      • for trivial cases
      • (a bit fragile)
      • though localised to mdo { ... }
    143. Devel::Declare
      • Even nicer syntax
      • mdo { mbind $x = 1; mbind $y = 2; mbind $z = $x + $y; say “$x * $y = $z”; }
    144. Devel::Declare
      • And cuter implementation:
      • mdo { mbind $x = 1; mbind $y = 2; mbind $z = $x + $y; say “$x * $y = $z”; }
    145. Devel::Declare
      • The problem:
      • mdo { mbind 1, sub { my $x = shift; mbind 2, sub { my $y = shift; mbind $x + $y, sub { my $z = shift; say “$x * $y = $z”; } ...
    146. Devel::Declare
      • No need to count nesting:
      • scope_inject
      • B::Hooks::EndOfScope
      • Use to inject a ; at the end of method declarations:
      • method foo ($x) { print $x; } # look Ma, no semicolon!
    147. Devel::Declare
      • mbind's scope_inject adds a “}”
      • mdo { mbind 1, sub { my $x = shift; mbind 2, sub { my $y = shift; mbind $x + $y, sub { my $z = shift; say “$x * $y = $z”; } # adds a closing brace }
    148. Devel::Declare
      • mbind's scope_inject adds a “}”
      • mdo { mbind 1, sub { my $x = shift; mbind 2, sub { my $y = shift; mbind $x + $y, sub { my $z = shift; say “$x * $y = $z”; } } # adds a closing brace }
    149. Devel::Declare
      • mbind's scope_inject adds a “}”
      • mdo { mbind 1, sub { my $x = shift; mbind 2, sub { my $y = shift; mbind $x + $y, sub { my $z = shift; say “$x * $y = $z”; } } } # adds a closing brace }
    150. Devel::Declare
      • mbind's scope_inject adds a “}”
      • mdo { mbind 1, sub { my $x = shift; mbind 2, sub { my $y = shift; mbind $x + $y, sub { my $z = shift; say “$x * $y = $z”; } } } } # closes block
    151. So...
      • We can now sequence commands!
      • mdo { mbind $x = 1; mbind $y = 2; mbind $z = $x + $y; say “$x * $y = $z”; }
    152. So...
      • We can now sequence commands!
      • in pure Perl!
    153. So...
      • OK, so this was big news in Haskell in 1990s
    154. So...
      • OK, so this was big news in Haskell in 1990s
      • Imperative languages have always done this
    155. What else can monads do ?
      • Sequencing
      • mdo { mbind $x = 1; mbind $y = 2; mbind $z = $x + $y; say “$x * $y = $z”; }
    156. What else can monads do ?
      • Sequencing
      • mdo { mbind $x = 1; mbind $y = 2; mbind $z = $x + $y; say “$x * $y = $z”; }
    157. What else can monads do ?
      • Sequencing
      • mdo { mbind $x = 1 ; mbind $y = 2 ; mbind $z = $x + $y ; say “$x * $y = $z”; }
    158. What else can monads do ?
      • Sequencing
      • mdo { mbind $x = 1 ; mbind $y = 2 ; mbind $z = $x + $y ; say “$x * $y = $z”; }
      • Programmable semicolon!
    159. Maybe
      • Success/Failure
      • mdo (Maybe) { mbind $FH = m_open('<', $file) ; mbind $line = <$FH> ; mbind $val = lookup(\%h, $line) ; say “Found $val!”; }
    160. Maybe
      • Success/Failure
      • mdo (Maybe) { mbind $FH = m_open('<', $file) ; mbind $line = <$FH> ; mbind $val = lookup(\%h, $line) ; say “Found $val!”; }
      • Will give up if can't open file, read a line from it, or look it up in a hash
    161. Maybe
      • Success/Failure
      • mdo (Maybe) { mbind $FH = m_open('<', $file) ; mbind $line = <$FH> ; mbind $val = lookup(\%h, $line) ; say “Found $val!”; }
      • Compare chain of if (foo) { if (bar) { ...
      • or eval { ... }
    162. Maybe $FH = open($file) $line = <$FH> $val = lookup ( $line ) say “Found $val”
    163. Maybe $FH = open($file) $line = <$FH> $val = lookup ( $line ) say “Found $val” ?
    164. Sequence
    165. Maybe ? ? ?
    166. Multiple (List)
    167. List $x = [1..10] $y = [1..10] guard $x+$y == 10 say “$x+$y=10”
    168. List
      • Cartesian product
      • mdo { mbind $x = [1..10] ; mbind $y = [1..10] ; mbind guard $x+$y == 10 ; say “$x+$y=10”; }
      • Run every $x against every $y and filter
    169. List
      • Cartesian product
      • mdo { mbind $x = [1..10] ; mbind $y = [1..10] ; mbind guard $x+$y == 10 ; say “$x+$y=10”; }
      • 1+9=10
      • 2+8=10
      • ...
    170. List
      • Cartesian product
      • mdo { mbind $x = [1..10] ; mbind $y = [1..10] ; mbind guard $x+$y == 10 ; say “$x+$y=10”; }
      • just like SQL
      • or LINQ
    171. List comprehension
      • More compact syntax
      • mcomp ($x <- [1..10]; $y <- [1..10]; $x+y==10) { say “$x+$y=10” }
    172. List
      • mdo { mbind $x = [1..10] ; mbind $y = [1..10] ; mbind guard $x+$y == 10 ; say “$x+$y=10”; }
      • We're actually calling mbind on a list
    173. List
      • mdo { mbind $x = [1..10] ; mbind $y = [1..10] ; mbind guard $x+$y == 10 ; say “$x+$y=10”; }
      • We're actually calling mbind on a list
      • autobox
    174. Continuations call_cc (&somefunc, ... ... ... )
    175. Continuations somefunc
    176. (clonable!) Continuations Somefunc for 1..3 {...}
    177. Next steps?
      • Devel::Declare + PPI
        • (parse till end of statement)
    178. Next steps?
      • Devel::Declare + PPI
        • (parse till end of statement)
        • $x ← foo(); # monadic
        • bar(); # also monadic!
        • my $x = 12; # “normal” value
        • (e.g. no more 'mbind' keyword)
    179. Perl++
      • Not really a functional language...
      • But you can take it surprisingly far
      • (CPAN++)
    180. What else can I do with monads?
      • Parsing
      • Error handling
      • SQL generation
    181. Wants monads now!
      • Techniques are valuable now
      • Nicely wrapped implementation will be ready soon....
    182. Wants monads now!
      • Techniques are valuable now
      • Nicely wrapped implementation will be ready soon....
      • Github: Acme::Monads – patches welcome
    183. Thanks!
      • questions?
    184. Thanks!
      • osfameron,
        • #london.pm, #perl.it, #northwestengland.pm
        • CPAN
        • github
      • Images
        • Red pepper section, by docman http://www.flickr.com/photos/docman/107252072/ (cc-by-nc)

    + osfameronosfameron, 3 months ago

    custom

    616 views, 1 favs, 0 embeds more stats

    The YAPC::EU::2009 (Lisbon) remix of my Functional more

    More info about this document

    CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

    Go to text version

    • Total Views 616
      • 616 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 7
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events