SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler 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

Mais conteúdo relacionado

Destaque (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レポートの舞台裏
 

Último

Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 

Último (20)

20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 

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