SlideShare a Scribd company logo
1 of 20
Download to read offline
State

                    2009   5   31   id:hiratara




2009   5   31
•
                          =   +

                • State

2009   5   31
(1) State



2009   5   31
State                                  →


                             State Int



                  String                        State Int String
                             State Int



                   Int                            State Int Int
                             State Int



                 MyType                        State Int MyType
                             State Int



                Maybe Bool                   State Int (Maybe Bool)

2009   5   31
State Int



                String                State Int String

                 quot;ABCquot;
                quot;12345quot;
                 quot;hogequot;   State Int



                  Int                  State Int Int

                  236
                 8974
2009   5   31
State

                           State Int



                  String               State Int String

                  quot;ABCquot;                      ???
                 quot;12345quot;                     ???
                  quot;hogequot;   State Int         ???

                    Int                 State Int Int

                   236                       ???
                  8974                       ???
2009   5   31
A). counter
       B).           counter   1
2009   5   31
A)   B)                 State




       A). counter
       B).                counter   1
2009   5   31
A).


                 1          quot;aquot;
                 2          quot;aaquot;
                 3          quot;aaaquot;
                      ...



2009   5   31
B).


                1          (quot;aquot;, 2)
                2          (quot;aaquot;, 3)
                3          (quot;aaaquot;, 4)
                     ...



2009   5   31
State Int String


                                         1           (quot;bquot;, 2)
                chars ‘b’        =       2           (quot;bbquot;, 3)
                                         3           (quot;bbbquot;, 4)
                                               ...

                                         1           (quot;*quot;, 2)
                chars ‘*’        =       2           (quot;**quot;, 3)
                                         3           (quot;***quot;, 4)
                                               ...

                                         1           (quot; quot;, 2)
                chars ‘ ’        =       2           (quot; quot;, 3)
                                         3           (quot; quot;, 4)
                                               ...
2009   5   31
State




                State Int String   Int -> (String, Int)

                                   1         (quot;*quot;, 2)
                                   2         (quot;**quot;, 3)
                                   3         (quot;***quot;, 4)
                                       ...




2009   5   31
State



                    s0                  v(s0)
                                                       (v(s0), s(s0))
                         s(s0)


                :
                    Int -> (String, Int)

                    1          (quot;*quot;, 2)
                    2          (quot;**quot;, 3)        (‘*’      s0 , s0 + 1)
                    3          (quot;***quot;, 4)
                         ...
2009   5   31
(2) return



2009   5   31
return                              State

                          State Int



                String    return              State Int String

                 quot;ABCquot;                              ???
                quot;12345quot;                             ???
                          State Int                 ???

                  Int      return              State Int Int

                 236                                ???
                                                    ???
2009   5   31
State Int



                String    return      State Int String

                 quot;ABCquot;                      ???
                quot;12345quot;                     ???
                          State Int         ???

                  Int      return      State Int Int

                 236                        ???
                                            ???
2009   5   31
State

                          State Int



                String    return      State Int String

                 quot;ABCquot;                 (“ABC”, s0)
                quot;12345quot;                (“12345, s0)
                          State Int        ???

                  Int      return      State Int Int

                 236                     (236, s0)
                                            ???
2009   5   31
State Int



                String    return      State Int String

                 quot;ABCquot;                 (“ABC”, s0)
                quot;12345quot;                (“12345, s0)
                          State Int    (v(s0), s(s0))

                  Int      return      State Int Int

                 236                     (236, s0)
                                       (v’(s0), s’(s0))
2009   5   31
• State                     s0
                    s0              v(s0)
                    s0                   s(s0)
                    2

                •         a       State              (a, s0)
                              ( return           )


2009   5   31
• State
                •                  State
                          State




                •                         State
                                  ( >>=           )
2009   5   31

More Related Content

Viewers also liked

Viewers also liked (19)

Types and perl language
Types and perl languageTypes and perl language
Types and perl language
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGI
 
20120526 hachioji.pm
20120526 hachioji.pm20120526 hachioji.pm
20120526 hachioji.pm
 
Git入門
Git入門Git入門
Git入門
 
Monads in perl
Monads in perlMonads in perl
Monads in perl
 
Math::Category
Math::CategoryMath::Category
Math::Category
 
定理3
定理3定理3
定理3
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopm
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LT
 
モデルから知るGit
モデルから知るGitモデルから知るGit
モデルから知るGit
 
Arrows in perl
Arrows in perlArrows in perl
Arrows in perl
 
AnyEvent and Plack
AnyEvent and PlackAnyEvent and Plack
AnyEvent and Plack
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Levenshtein Automata
Levenshtein AutomataLevenshtein Automata
Levenshtein Automata
 
Monads in python
Monads in pythonMonads in python
Monads in python
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門
 
すごいMonad入門
すごいMonad入門すごいMonad入門
すごいMonad入門
 
Currying in perl
Currying in perlCurrying in perl
Currying in perl
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Stateモナドの解説 中編

  • 1. State 2009 5 31 id:hiratara 2009 5 31
  • 2. = + • State 2009 5 31
  • 4. State → State Int String State Int String State Int Int State Int Int State Int MyType State Int MyType State Int Maybe Bool State Int (Maybe Bool) 2009 5 31
  • 5. State Int String State Int String quot;ABCquot; quot;12345quot; quot;hogequot; State Int Int State Int Int 236 8974 2009 5 31
  • 6. State State Int String State Int String quot;ABCquot; ??? quot;12345quot; ??? quot;hogequot; State Int ??? Int State Int Int 236 ??? 8974 ??? 2009 5 31
  • 7. A). counter B). counter 1 2009 5 31
  • 8. A) B) State A). counter B). counter 1 2009 5 31
  • 9. A). 1 quot;aquot; 2 quot;aaquot; 3 quot;aaaquot; ... 2009 5 31
  • 10. B). 1 (quot;aquot;, 2) 2 (quot;aaquot;, 3) 3 (quot;aaaquot;, 4) ... 2009 5 31
  • 11. State Int String 1 (quot;bquot;, 2) chars ‘b’ = 2 (quot;bbquot;, 3) 3 (quot;bbbquot;, 4) ... 1 (quot;*quot;, 2) chars ‘*’ = 2 (quot;**quot;, 3) 3 (quot;***quot;, 4) ... 1 (quot; quot;, 2) chars ‘ ’ = 2 (quot; quot;, 3) 3 (quot; quot;, 4) ... 2009 5 31
  • 12. State State Int String Int -> (String, Int) 1 (quot;*quot;, 2) 2 (quot;**quot;, 3) 3 (quot;***quot;, 4) ... 2009 5 31
  • 13. State s0 v(s0) (v(s0), s(s0)) s(s0) : Int -> (String, Int) 1 (quot;*quot;, 2) 2 (quot;**quot;, 3) (‘*’ s0 , s0 + 1) 3 (quot;***quot;, 4) ... 2009 5 31
  • 15. return State State Int String return State Int String quot;ABCquot; ??? quot;12345quot; ??? State Int ??? Int return State Int Int 236 ??? ??? 2009 5 31
  • 16. State Int String return State Int String quot;ABCquot; ??? quot;12345quot; ??? State Int ??? Int return State Int Int 236 ??? ??? 2009 5 31
  • 17. State State Int String return State Int String quot;ABCquot; (“ABC”, s0) quot;12345quot; (“12345, s0) State Int ??? Int return State Int Int 236 (236, s0) ??? 2009 5 31
  • 18. State Int String return State Int String quot;ABCquot; (“ABC”, s0) quot;12345quot; (“12345, s0) State Int (v(s0), s(s0)) Int return State Int Int 236 (236, s0) (v’(s0), s’(s0)) 2009 5 31
  • 19. • State s0 s0 v(s0) s0 s(s0) 2 • a State (a, s0) ( return ) 2009 5 31
  • 20. • State • State State • State ( >>= ) 2009 5 31