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

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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