SlideShare a Scribd company logo
Arrows in Perl
2011.12.10 hiratara
d.hatena.ne.jp/hiratara

twitter.com/hiratara



Perl
d.hatena.ne.jp/hiratara

twitter.com/hiratara



Perl
Perl

Haskell
Perl

Haskell
Perl

Haskell
Perl

Haskell
Arrows in perl
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
Data::Monad

my $result = Data::Monad::Base::Sugar::for {
    pick my $x => sub { scalar_list 1 .. 100 };
    pick my $y => sub { scalar_list $x .. 100 };
    pick my $z => sub {
     scalar_list $y .. ($x + $y > 100 ? 100 : $x + $y)
    };
    satisfy { $x**2 + $y**2 == $z**2 };
    yield { $x, $y, $z }
};
return    >>=

return :: a -> m a
>>= :: m a -> (a -> m b) -> m b
return               >>=
ma       mb         mb       mc        ma        mc

     f        >=>        g        ==     f >=> g
a         b         b        c         a        c

ma                  ma       mb        ma        mb
 return       >=>        f        ==         f
a                   a        b         a         b
(2)

                              2



     fmap                return   join

fmap :: a -> b -> (m a -> m b)
join :: m (m a) -> m a
(3)
η⊗id           id⊗η
I⊗M              M⊗M            M⊗I

                     μ
      λ                     ρ

                 M
(                 )
              0×id                   id×0
(*, n)               (0, n) (n, 0)              (n, *)

                              (+)
         π’                             π

                          n
(            )
       fmap return              return
id.fmap            fmap.fmap               fmap.id

                         join
       id                             id

                    fmap
(            )
       fmap return              return
id.fmap            fmap.fmap               fmap.id

                         join
       id                             id

                    fmap
Arrows in perl
Arrows

John Hughes   2000
Monad    Arrow


                 (Haskell    )
                                 mb

                             f
                         a
Arrows

                         f :: m b c   b
                     a
Arrows

arr >>> first                    ↝

arr :: a -> b -> (a ↝ b)

>>> :: (a ↝ b) -> (b ↝ c) -> (a ↝ c)

first :: (a ↝ b) -> (a × c ↝ b × c)
Arrow
        package Arrow;

        sub arr {
        	 my ($class, $code) = @_;
        	 die "not implemented";
        }

        sub first {
        	 my $self = shift;
        	 die "not implemented";
        }

        sub next {
        	 my ($self, $arrow) = @_;
        	 die "not implemented";
        }
first
     a↝b       a   b

     >>>

     arr           ↝


a          f   b           a      arr f :: a ↝ b
                                                    b

               g   arr   arr f >>> arr g :: a ↝ c
                                                        arr g :: b ↝ c

    g.f
               c                                    c
first
           Arrow ↝

           a                    c   a×c

f :: a↝b             g :: c↝d         f *** g :: a×c↝b×d




           b                    d   b×d
(f *** g) >>> (f’ *** g’)   (f >>> f’) *** (g >>> g’)


      f           g                f          g




       f’         g’               f’        g’
(f *** g) >>> (f’ *** g’)   (f >>> f’) *** (g >>> g’)


      f           g                f          g




       f’         g’               f’        g’
premonoidal category

 f ⋉ id = first f     a×b          a×b
 id ⋊ f = second f
                        f ⋉ id
                     a’×b            (f>>>f’) ⋉ id

                        f’ ⋉ id

                     a’’×b        a’’×b
premonoidal category

 f ⋉ id = first f     a×b          a×b
 id ⋊ f = second f
                        f ⋉ id
                     a’×b            (f>>>f’) ⋉ id

                        f’ ⋉ id

                     a’’×b        a’’×b
central

 f *** g ≡ first f >>> second g
 first f >>> second - = second - >>> first f
 first - >>> second f = second f >>> first -
           f central

 arr f   central

 f |x g ≡ first f >>> second (arr g)
 (                                     10.2)
Freyd category

                     premonoidal category


(central        central          )

           a -> b            Arrow a ↝ b
     arr              Freyd category
first   (   )
second              ***
 sub second {
 	 my $self = shift;
 	 my $swap = (ref $self)->arr(sub { $_[1], $_[0] });
 	 $swap->next($self->first)->next($swap);
 }



 sub parallel {
 	 my ($self, $arrow) = @_;
 	 $self->first->next($arrow->second);
 }

                     fst f >>> snd g
                       id        g
               C            C        D

                       f             id
               A              B            B
&&&
     sub split {
     	 my ($self, $arrow) = @_;
     	 (ref $self)->arr(sub {
     	 	 my $args = [@_];
     	 	 $args, $args;
     	 })->next($self->parallel($arrow));
     }

            A                                         A
                                                                  arr id
                                         arr id
                                                  arr <id, id>
     f                 g             A       arr π
                                                     A×A     arr π’
                                                                           A
            f &&&g               f                                             g
                                                          f *** g
                                             arr π               arr π’
B
    arr π
            B×C   arr π’
                           C         B               B×C                   C
(1):


Perl
f : A×B → C×D
(1):


first :: a × b × c -> d × e
 -> (a × b × c × y × z -> d × e × y × z)
                        5
(1):
 f                              (@v1 )
     sub first {
     	 my $self = shift;
     	 (ref $self)->arr(sub {
     	 	 my (@v1, @v2) = @_;
     	 	 $self->(@v1), @v2;
     	 });
     }




                 first              2
(A × B) × (C × D)
package Arrow::Subroutine;
use parent qw/Arrow/;

sub arr {
	 my ($class, $code) = @_;
	 bless $code, $class;
}

sub first {
	 my $self = shift;
	 (ref $self)->arr(sub {
	 	 my ($v1, $v2) = @_;
	 	 [$self->(@$v1)], $v2;
	 });
}

sub next {
	 my ($self, $arrow) = @_;
	 (ref $self)->arr(sub { $arrow->($self->(@_)) });
}
my $arr3 = Arrow::Subroutine->arr(sub { 3 });
my $arr4 = Arrow::Subroutine->arr(sub { 4 });
my $arrow_add = Arrow::Subroutine->arr(sub {
	 $_[0]->[0] + $_[1]->[0];
});
my $arr3_plus_4 = $arr3->split($arr4)->next($arrow_add);

print $arr3_plus_4->(), "n";


               3
                          π

         ()
               3 &&& 4               +
                         Int×Int             Int
                          π’
               4
(2):


              >>> arr

first
first
       a   π    a×c      π’    c


   f               f×return        return


           π              π’
   mb          mb×mc           mc
                  φ

               m(b×c)
package Arrow::Kleisli;
use parent qw/Arrow/;

sub _safe_name($) {
    my $name = shift;
    $name =~ s|::|__|g;
    return "__$name";
}

sub new_class {
    my $class = shift;
    my ($monad) = @_;

    my $class_name = "$class::" . _safe_name($monad);
    unless ($class_name->isa($class)) {
        no strict qw/refs/;
        @{"$class_name::ISA"} = ($class);
        *{"$class_name::monad"} = sub { $monad };
        *{"$class_name::new_class"} = sub {
            die "Don't call the new_class() method from sub classes.";
        };
    }

    return $class_name;
}

sub monad { die "Implement this method in sub classes" }
...
sub new {
	 my ($class, $kleisli) = @_;
	 bless $kleisli, $class;
}

sub arr {
	 my ($class, $code) = @_;
	 $class->new(sub {
	 	 $class->monad->unit($code->(@_));
	 });
}

sub next {
	 my ($self, $arrow) = @_;
	 (ref $self)->new(sub {
	 	 my @v = @_;
	 	 $self->(@v)->flat_map($arrow);
	 });
}
sub first {
	 my $self = shift;
	 my $class = (ref $self);
	 my $monad = $class->monad;

	   $class->new(sub {
	   	 my ($args1, $args2) = @_;
	   	 $monad->sequence(
	   	 	 $self->(@$args1)->map(sub {[@_]}),
	   	 	 $monad->unit(@$args2)->map(sub {[@_]}),
	   	 );
	   });
}
arr 10
                              arr π

     ()
          arr 10 &&& arr 2             div
                             Int×Int         Int
                              arr π’
            arr 2




div :: Int×Int ↝ Int = Int×Int → Maybe Int
my $class = Arrow::Kleisli->new_class('Data::Monad::Maybe');
my $arrow10 = $class->arr(sub { 10 });
my $arrow2 = $class->arr(sub { 2 });
my $arrow_div = $class->new(sub {
	 $_[1][0] == 0 ? nothing : just ($_[0][0] / $_[1][0]);
});
my $arrow10_div_2 = $arrow10->split($arrow2)-
>next($arrow_div);

my $maybe = $arrow10_div_2->();
print $maybe->is_nothing ? 'NOTHING' : $maybe->value;
print "n";
Arrows

Stream            Arrows
:
Arrows

 mm        join       return
                  m            id



           >>>         arr
 ↝⊗↝              ↝            Hom
(            )

            arr⊗id              id⊗arr
Hom⊗↝                ↝⊗↝                   ↝⊗Hom

                          >>>
        λ                              ρ

                      ↝
Arrows

first

LL       Arrows
http://d.hatena.ne.jp/m-hiyama/20111107/1320624410
Arrows in perl

More Related Content

PDF
Introduction to ad-3.4, an automatic differentiation library in Haskell
PDF
Top 10 php classic traps
PDF
Monads in perl
PDF
PHP for Python Developers
PPTX
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Introduction to ad-3.4, an automatic differentiation library in Haskell
Top 10 php classic traps
Monads in perl
PHP for Python Developers
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.

What's hot (20)

PPTX
Python decorators
PDF
Stupid Awesome Python Tricks
PDF
Introdução ao Perl 6
PDF
Python decorators (中文)
PDF
Get on with Field API
PDF
Functional Pe(a)rls - the Purely Functional Datastructures edition
ODP
Decorators in Python
PPT
Arrays in php
PPT
Python легко и просто. Красиво решаем повседневные задачи
KEY
Pyimproved again
PDF
Hacking Parse.y with ujihisa
PDF
Wx::Perl::Smart
PDF
Part 7
PDF
Perl.Hacks.On.Vim
PDF
Descobrindo a linguagem Perl
PDF
Python Fundamentals - Basic
PDF
Climbing the Abstract Syntax Tree (PHP UK 2018)
PDF
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
PDF
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Python decorators
Stupid Awesome Python Tricks
Introdução ao Perl 6
Python decorators (中文)
Get on with Field API
Functional Pe(a)rls - the Purely Functional Datastructures edition
Decorators in Python
Arrays in php
Python легко и просто. Красиво решаем повседневные задачи
Pyimproved again
Hacking Parse.y with ujihisa
Wx::Perl::Smart
Part 7
Perl.Hacks.On.Vim
Descobrindo a linguagem Perl
Python Fundamentals - Basic
Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Ad

Similar to Arrows in perl (20)

PDF
Math::Category
PDF
Clojure: The Art of Abstraction
KEY
Verification with LoLA: 7 Implementation
KEY
Haskellで学ぶ関数型言語
PPTX
Short Transitive Signatures For Directed Trees
PDF
Examples for loopless
PDF
Thinking Functionally In Ruby
PPTX
Parsing using graphs
KEY
June10 2010-os
PPT
Paper
KEY
Perl saved a lady.
PPTX
Set data structure 2
PDF
RubyConf Argentina 2011
PDF
Plc (1)
PDF
Functional Programming In Mathematica
PDF
Introduction to Haskell@Open Source Conference 2007 Hokkaido
PDF
Peyton jones-2011-type classes
PPTX
Bloom filters
PDF
MapReduce for Parallel Trace Validation of LTL Properties
PPTX
Class 28: Entropy
Math::Category
Clojure: The Art of Abstraction
Verification with LoLA: 7 Implementation
Haskellで学ぶ関数型言語
Short Transitive Signatures For Directed Trees
Examples for loopless
Thinking Functionally In Ruby
Parsing using graphs
June10 2010-os
Paper
Perl saved a lady.
Set data structure 2
RubyConf Argentina 2011
Plc (1)
Functional Programming In Mathematica
Introduction to Haskell@Open Source Conference 2007 Hokkaido
Peyton jones-2011-type classes
Bloom filters
MapReduce for Parallel Trace Validation of LTL Properties
Class 28: Entropy
Ad

More from Masahiro Honma (20)

PDF
レンズ (ぶつかり稽古の没プレゼン)
PDF
すべてが@__kanになる
PDF
Types and perl language
PDF
Currying in perl
PDF
カレーとHokkaidopm
PDF
モナモナ言うモナド入門.tar.gz
PDF
モナモナ言うモナド入門
PDF
Levenshtein Automata
PDF
20120526 hachioji.pm
KEY
循環参照のはなし
KEY
Hachioji.pm in Machida の LT
PDF
ウヰスキーとPSGI
PDF
モデルから知るGit
PDF
YAPCレポートの舞台裏
PDF
Git入門
PDF
AnyEvent and Plack
PDF
Stateモナドの解説 後編
PDF
Stateモナドの解説 中編
KEY
Stateモナドの解説 前編
KEY
定理3
レンズ (ぶつかり稽古の没プレゼン)
すべてが@__kanになる
Types and perl language
Currying in perl
カレーとHokkaidopm
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門
Levenshtein Automata
20120526 hachioji.pm
循環参照のはなし
Hachioji.pm in Machida の LT
ウヰスキーとPSGI
モデルから知るGit
YAPCレポートの舞台裏
Git入門
AnyEvent and Plack
Stateモナドの解説 後編
Stateモナドの解説 中編
Stateモナドの解説 前編
定理3

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
Review of recent advances in non-invasive hemoglobin estimation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Monthly Chronicles - July 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
A Presentation on Artificial Intelligence

Arrows in perl

  • 9. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 10. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 11. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 12. Data::Monad my $result = Data::Monad::Base::Sugar::for { pick my $x => sub { scalar_list 1 .. 100 }; pick my $y => sub { scalar_list $x .. 100 }; pick my $z => sub { scalar_list $y .. ($x + $y > 100 ? 100 : $x + $y) }; satisfy { $x**2 + $y**2 == $z**2 }; yield { $x, $y, $z } };
  • 13. return >>= return :: a -> m a >>= :: m a -> (a -> m b) -> m b return >>=
  • 14. ma mb mb mc ma mc f >=> g == f >=> g a b b c a c ma ma mb ma mb return >=> f == f a a b a b
  • 15. (2) 2 fmap return join fmap :: a -> b -> (m a -> m b) join :: m (m a) -> m a
  • 16. (3)
  • 17. η⊗id id⊗η I⊗M M⊗M M⊗I μ λ ρ M
  • 18. ( ) 0×id id×0 (*, n) (0, n) (n, 0) (n, *) (+) π’ π n
  • 19. ( ) fmap return return id.fmap fmap.fmap fmap.id join id id fmap
  • 20. ( ) fmap return return id.fmap fmap.fmap fmap.id join id id fmap
  • 23. Monad Arrow (Haskell ) mb f a Arrows f :: m b c b a
  • 24. Arrows arr >>> first ↝ arr :: a -> b -> (a ↝ b) >>> :: (a ↝ b) -> (b ↝ c) -> (a ↝ c) first :: (a ↝ b) -> (a × c ↝ b × c)
  • 25. Arrow package Arrow; sub arr { my ($class, $code) = @_; die "not implemented"; } sub first { my $self = shift; die "not implemented"; } sub next { my ($self, $arrow) = @_; die "not implemented"; }
  • 26. first a↝b a b >>> arr ↝ a f b a arr f :: a ↝ b b g arr arr f >>> arr g :: a ↝ c arr g :: b ↝ c g.f c c
  • 27. first Arrow ↝ a c a×c f :: a↝b g :: c↝d f *** g :: a×c↝b×d b d b×d
  • 28. (f *** g) >>> (f’ *** g’) (f >>> f’) *** (g >>> g’) f g f g f’ g’ f’ g’
  • 29. (f *** g) >>> (f’ *** g’) (f >>> f’) *** (g >>> g’) f g f g f’ g’ f’ g’
  • 30. premonoidal category f ⋉ id = first f a×b a×b id ⋊ f = second f f ⋉ id a’×b (f>>>f’) ⋉ id f’ ⋉ id a’’×b a’’×b
  • 31. premonoidal category f ⋉ id = first f a×b a×b id ⋊ f = second f f ⋉ id a’×b (f>>>f’) ⋉ id f’ ⋉ id a’’×b a’’×b
  • 32. central f *** g ≡ first f >>> second g first f >>> second - = second - >>> first f first - >>> second f = second f >>> first - f central arr f central f |x g ≡ first f >>> second (arr g) ( 10.2)
  • 33. Freyd category premonoidal category (central central ) a -> b Arrow a ↝ b arr Freyd category
  • 34. first ( )
  • 35. second *** sub second { my $self = shift; my $swap = (ref $self)->arr(sub { $_[1], $_[0] }); $swap->next($self->first)->next($swap); } sub parallel { my ($self, $arrow) = @_; $self->first->next($arrow->second); } fst f >>> snd g id g C C D f id A B B
  • 36. &&& sub split { my ($self, $arrow) = @_; (ref $self)->arr(sub { my $args = [@_]; $args, $args; })->next($self->parallel($arrow)); } A A arr id arr id arr <id, id> f g A arr π A×A arr π’ A f &&&g f g f *** g arr π arr π’ B arr π B×C arr π’ C B B×C C
  • 37. (1): Perl f : A×B → C×D
  • 38. (1): first :: a × b × c -> d × e -> (a × b × c × y × z -> d × e × y × z) 5
  • 39. (1): f (@v1 ) sub first { my $self = shift; (ref $self)->arr(sub { my (@v1, @v2) = @_; $self->(@v1), @v2; }); } first 2 (A × B) × (C × D)
  • 40. package Arrow::Subroutine; use parent qw/Arrow/; sub arr { my ($class, $code) = @_; bless $code, $class; } sub first { my $self = shift; (ref $self)->arr(sub { my ($v1, $v2) = @_; [$self->(@$v1)], $v2; }); } sub next { my ($self, $arrow) = @_; (ref $self)->arr(sub { $arrow->($self->(@_)) }); }
  • 41. my $arr3 = Arrow::Subroutine->arr(sub { 3 }); my $arr4 = Arrow::Subroutine->arr(sub { 4 }); my $arrow_add = Arrow::Subroutine->arr(sub { $_[0]->[0] + $_[1]->[0]; }); my $arr3_plus_4 = $arr3->split($arr4)->next($arrow_add); print $arr3_plus_4->(), "n"; 3 π () 3 &&& 4 + Int×Int Int π’ 4
  • 42. (2): >>> arr first
  • 43. first a π a×c π’ c f f×return return π π’ mb mb×mc mc φ m(b×c)
  • 44. package Arrow::Kleisli; use parent qw/Arrow/; sub _safe_name($) { my $name = shift; $name =~ s|::|__|g; return "__$name"; } sub new_class { my $class = shift; my ($monad) = @_; my $class_name = "$class::" . _safe_name($monad); unless ($class_name->isa($class)) { no strict qw/refs/; @{"$class_name::ISA"} = ($class); *{"$class_name::monad"} = sub { $monad }; *{"$class_name::new_class"} = sub { die "Don't call the new_class() method from sub classes."; }; } return $class_name; } sub monad { die "Implement this method in sub classes" } ...
  • 45. sub new { my ($class, $kleisli) = @_; bless $kleisli, $class; } sub arr { my ($class, $code) = @_; $class->new(sub { $class->monad->unit($code->(@_)); }); } sub next { my ($self, $arrow) = @_; (ref $self)->new(sub { my @v = @_; $self->(@v)->flat_map($arrow); }); }
  • 46. sub first { my $self = shift; my $class = (ref $self); my $monad = $class->monad; $class->new(sub { my ($args1, $args2) = @_; $monad->sequence( $self->(@$args1)->map(sub {[@_]}), $monad->unit(@$args2)->map(sub {[@_]}), ); }); }
  • 47. arr 10 arr π () arr 10 &&& arr 2 div Int×Int Int arr π’ arr 2 div :: Int×Int ↝ Int = Int×Int → Maybe Int
  • 48. my $class = Arrow::Kleisli->new_class('Data::Monad::Maybe'); my $arrow10 = $class->arr(sub { 10 }); my $arrow2 = $class->arr(sub { 2 }); my $arrow_div = $class->new(sub { $_[1][0] == 0 ? nothing : just ($_[0][0] / $_[1][0]); }); my $arrow10_div_2 = $arrow10->split($arrow2)- >next($arrow_div); my $maybe = $arrow10_div_2->(); print $maybe->is_nothing ? 'NOTHING' : $maybe->value; print "n";
  • 49. Arrows Stream Arrows
  • 50. : Arrows mm join return m id >>> arr ↝⊗↝ ↝ Hom
  • 51. ( ) arr⊗id id⊗arr Hom⊗↝ ↝⊗↝ ↝⊗Hom >>> λ ρ ↝

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: \n
  • #6: \n
  • #7: \n
  • #8: \n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: \n
  • #13: \n
  • #14: \n
  • #15: \n
  • #16: \n
  • #17: &amp;#x3010;5&amp;#x5206;&amp;#x3011;\n
  • #18: \n
  • #19: \n
  • #20: \n
  • #21: \n
  • #22: \n
  • #23: \n
  • #24: \n
  • #25: &amp;#x3010;10&amp;#x5206;&amp;#x3011;\n
  • #26: \n
  • #27: &amp;#x9EC4;&amp;#x8272;&amp;#x306E;&amp;#x90E8;&amp;#x5206;&amp;#x304C;&amp;#x95A2;&amp;#x6570;&amp;#x3067;&amp;#x306F;&amp;#x306A;&amp;#x304F;&amp;#x578B;&amp;#x306A;&amp;#x306E;&amp;#x304C;&amp;#x30DD;&amp;#x30A4;&amp;#x30F3;&amp;#x30C8;&amp;#x3002;\n
  • #28: \n
  • #29: \n
  • #30: &amp;#x7D50;&amp;#x5408;&amp;#x5247;&amp;#x3092;&amp;#x6E80;&amp;#x305F;&amp;#x3059;&amp;#x3088;&amp;#x3046;&amp;#x306A;&amp;#x5B9A;&amp;#x7FA9;&amp;#x3092;&amp;#x3057;&amp;#x3066;&amp;#x304A;&amp;#x3044;&amp;#x305F;&amp;#x65B9;&amp;#x304C;&amp;#x53B3;&amp;#x5BC6;&amp;#x3060;&amp;#x3057;&amp;#x4F7F;&amp;#x3044;&amp;#x3084;&amp;#x3059;&amp;#x3044;\n
  • #31: \n
  • #32: &amp;#x3010;15&amp;#x5206;&amp;#x3011;\n
  • #33: \n
  • #34: &amp;#x4EFB;&amp;#x610F;&amp;#x306E;&amp;#x30A2;&amp;#x30ED;&amp;#x30FC;&amp;#x306B;&amp;#x5BFE;&amp;#x3057;&amp;#x3066;&amp;#x540C;&amp;#x3058;&amp;#x5B9F;&amp;#x88C5;&amp;#x304C;&amp;#x5229;&amp;#x7528;&amp;#x53EF;&amp;#x80FD;&amp;#x3002;&amp;#x62BD;&amp;#x8C61;&amp;#x5316;&amp;#x306E;&amp;#x52B9;&amp;#x529B;&amp;#x3002;\n
  • #35: &amp;#x4EFB;&amp;#x610F;&amp;#x306E;&amp;#x30A2;&amp;#x30ED;&amp;#x30FC;&amp;#x306B;&amp;#x5BFE;&amp;#x3057;&amp;#x3066;&amp;#x540C;&amp;#x3058;&amp;#x5B9F;&amp;#x88C5;&amp;#x304C;&amp;#x5229;&amp;#x7528;&amp;#x53EF;&amp;#x80FD;&amp;#x3002;&amp;#x62BD;&amp;#x8C61;&amp;#x5316;&amp;#x306E;&amp;#x52B9;&amp;#x529B;&amp;#x3002;\n
  • #36: \n
  • #37: \n
  • #38: \n
  • #39: &amp;#x3010;20&amp;#x5206;&amp;#x3011;\n
  • #40: \n
  • #41: \n
  • #42: \n
  • #43: &amp;#x30E2;&amp;#x30CA;&amp;#x30C9;&amp;#x3092;&amp;#x578B;&amp;#x30D1;&amp;#x30E9;&amp;#x30E1;&amp;#x30FC;&amp;#x30BF;&amp;#x3068;&amp;#x3057;&amp;#x3066;&amp;#x6271;&amp;#x3046;&amp;#x305F;&amp;#x3081;&amp;#x306E;&amp;#x304A;&amp;#x307E;&amp;#x3058;&amp;#x306A;&amp;#x3044;\n
  • #44: return&amp;#x3084;bind&amp;#x3092;arrow&amp;#x306E;&amp;#x8A00;&amp;#x8449;&amp;#x306B;&amp;#x7FFB;&amp;#x8A33;&amp;#x3057;&amp;#x3066;&amp;#x308B;&amp;#x3060;&amp;#x3051;\n
  • #45: &amp;#x3055;&amp;#x3063;&amp;#x304D;&amp;#x306E;&amp;#x56F3;&amp;#x3092;&amp;#x5143;&amp;#x306B;&amp;#x5B9F;&amp;#x88C5;&amp;#x3002;map&amp;#x306E;&amp;#x8FBA;&amp;#x308A;&amp;#x306F;&amp;#x578B;&amp;#x3092;&amp;#x305D;&amp;#x308D;&amp;#x3048;&amp;#x308B;&amp;#x304A;&amp;#x307E;&amp;#x3058;&amp;#x306A;&amp;#x3044;\n
  • #46: &amp;#x3010;25&amp;#x5206;&amp;#x3011;&amp;#x3088;&amp;#x304F;&amp;#x3042;&amp;#x308B;0&amp;#x9664;&amp;#x7B97;&amp;#x306E;&amp;#x4F8B;\n
  • #47: &amp;#x3088;&amp;#x304F;&amp;#x3042;&amp;#x308B;0&amp;#x9664;&amp;#x7B97;&amp;#x306E;&amp;#x4F8B;\n
  • #48: \n
  • #49: &amp;#x4E0A;&amp;#x306F;&amp;#x81EA;&amp;#x5DF1;&amp;#x95A2;&amp;#x624B;&amp;#x570F;&amp;#x3002;&amp;#x4E0B;&amp;#x306F;Profunctor&amp;#x306E;&amp;#x570F;&amp;#x3002;&amp;#x4E0B;&amp;#x306E;&amp;#x65B9;&amp;#x304C;&amp;#x9065;&amp;#x304B;&amp;#x306B;&amp;#x96E3;&amp;#x3057;&amp;#x304F;&amp;#x3066;&amp;#x3088;&amp;#x304F;&amp;#x308F;&amp;#x304B;&amp;#x3089;&amp;#x306A;&amp;#x3044;&amp;#x3002;&amp;#x7279;&amp;#x306B; &amp;#x2297;&amp;#x306E;&amp;#x5B9A;&amp;#x7FA9;\n
  • #50: \n
  • #51: \n
  • #52: \n
  • #53: \n