SlideShare una empresa de Scribd logo
1 de 28
State

    2009   5   31   id:hiratara
•
•   State
•               URI   Comparable
    Interface
      Comparable
         URI
(1)
Bool        length
      Float         fst
     Integer       take
     MyType         zip
   (Int, Bool)    myfunc
     [Char]         id
  Maybe String       ...
Int → Int → Int
         ...
Bool        length
      Float         fst
     Integer       take
     MyType         zip
   (Int, Bool)    myfunc
     [Char]         id
  Maybe String       ...
Int → Int → Int
         ...
Bool        length
      Float         fst
     Integer       take
     MyType         zip
   (Int, Bool)    myfunc
     [Char]         id
  Maybe String       ...
Int → Int → Int
         ...
id

      f -> f quot;abcquot;   [Char]
 id                                   head

[Char] -> [Char]                         Char   id
                             length
            take
                        Int      id
id

      f -> f quot;abcquot;   [Char]
 id                                   head

[Char] → [Char]                          Char   id
                             length
            take
                        Int      id
(2)
:


                Maybe

[Char]                          Maybe [Char]

                        Maybe

       length                          liftM length

                Maybe

     Int                         Maybe Int
[]

[Char]                 [ [Char] ]

                  []

    length                    liftM length

             []

 Int                     [ Int ]
[]                           [Char]


              []

[Char]                  [ [Char] ]

                   []

     length                    liftM length

              []

 Int                      [ Int ]
liftM                     Maybe


                     []

        [Char]                    [ [Char] ]

                           []

            length                       liftM length

                     []

         Int                        [ Int ]
(3) return
:
           Maybe


           return
[Char]              Maybe [Char]




           return
 Int                 Maybe Int
[]



         return
[Char]            [ [Char] ]




         return
 Int                [ Int ]
return
            State



            return
 [Char]                         State [Char]
            return
  Bool                           State Bool
            return
MyType                         State MyType

            return
IO String                     State (IO String)
(4) (>>=)
Maybe




[Char]                  Maybe [Char]


                 func



 Int                     Maybe Int
         Maybe
(>>=)
              Maybe




   [Char]                       Maybe [Char]
                        (>>=)



                      func             (=<<) func



        Int                      Maybe Int
              Maybe
State



                 (>>=)
[Char]                   State [Char]
          func1
                                 (=<<) func1
                 (>>=)
 Int                       State Int
          func2
                                 (=<<) func2

MyType                   State MyType
return

                  IO




   [Char]                  IO [Char]



         length

                  return
     Int                    IO Int
IO




[Char]                   IO [Char]

            return . length
   length

            return
 Int                          IO Int
(>>=)                         liftM

                 IO




  [Char]              (>>=)   IO [Char]

                 return . length
        length                     (=<<) $ return . length


                 return
    Int                            IO Int
•

• return

• (>>=)
•


•

•   State
• Haskell          Kleisli triple
                   Monad

• Kleisli triple        Monad



• Kleisli triple         liftM
                           (            Monad
                                    )

Más contenido relacionado

La actualidad más candente

La actualidad más candente (11)

05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Strings
StringsStrings
Strings
 
Strinng Classes in c++
Strinng Classes in c++Strinng Classes in c++
Strinng Classes in c++
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
14 strings
14 strings14 strings
14 strings
 
Templating with your {{mustache}}js
Templating with your {{mustache}}jsTemplating with your {{mustache}}js
Templating with your {{mustache}}js
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Fundamental JS
Fundamental JSFundamental JS
Fundamental JS
 
13 Strings and text processing
13 Strings and text processing13 Strings and text processing
13 Strings and text processing
 
Strings
StringsStrings
Strings
 

Más de Masahiro Honma

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)Masahiro Honma
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになるMasahiro Honma
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl languageMasahiro Honma
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopmMasahiro Honma
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzMasahiro Honma
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門Masahiro Honma
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LTMasahiro Honma
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGIMasahiro Honma
 
モデルから知るGit
モデルから知るGitモデルから知るGit
モデルから知るGitMasahiro Honma
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏Masahiro Honma
 

Más de Masahiro Honma (20)

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになる
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl language
 
Currying in perl
Currying in perlCurrying in perl
Currying in perl
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopm
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gz
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門
 
Perl saved a lady.
Perl saved a lady.Perl saved a lady.
Perl saved a lady.
 
Levenshtein Automata
Levenshtein AutomataLevenshtein Automata
Levenshtein Automata
 
20120526 hachioji.pm
20120526 hachioji.pm20120526 hachioji.pm
20120526 hachioji.pm
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Arrows in perl
Arrows in perlArrows in perl
Arrows in perl
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LT
 
Monads in perl
Monads in perlMonads in perl
Monads in perl
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGI
 
モデルから知るGit
モデルから知るGitモデルから知るGit
モデルから知るGit
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
 
Git入門
Git入門Git入門
Git入門
 
AnyEvent and Plack
AnyEvent and PlackAnyEvent and Plack
AnyEvent and Plack
 
Math::Category
Math::CategoryMath::Category
Math::Category
 

Último

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
 
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
 
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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Último (20)

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
 
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
 
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
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Stateモナドの解説 前編

  • 1. State 2009 5 31 id:hiratara
  • 2. • • State
  • 3. URI Comparable Interface Comparable URI
  • 4. (1)
  • 5. Bool length Float fst Integer take MyType zip (Int, Bool) myfunc [Char] id Maybe String ... Int → Int → Int ...
  • 6. Bool length Float fst Integer take MyType zip (Int, Bool) myfunc [Char] id Maybe String ... Int → Int → Int ...
  • 7. Bool length Float fst Integer take MyType zip (Int, Bool) myfunc [Char] id Maybe String ... Int → Int → Int ...
  • 8. id f -> f quot;abcquot; [Char] id head [Char] -> [Char] Char id length take Int id
  • 9. id f -> f quot;abcquot; [Char] id head [Char] → [Char] Char id length take Int id
  • 10. (2)
  • 11. : Maybe [Char] Maybe [Char] Maybe length liftM length Maybe Int Maybe Int
  • 12. [] [Char] [ [Char] ] [] length liftM length [] Int [ Int ]
  • 13. [] [Char] [] [Char] [ [Char] ] [] length liftM length [] Int [ Int ]
  • 14. liftM Maybe [] [Char] [ [Char] ] [] length liftM length [] Int [ Int ]
  • 16. : Maybe return [Char] Maybe [Char] return Int Maybe Int
  • 17. [] return [Char] [ [Char] ] return Int [ Int ]
  • 18. return State return [Char] State [Char] return Bool State Bool return MyType State MyType return IO String State (IO String)
  • 20. Maybe [Char] Maybe [Char] func Int Maybe Int Maybe
  • 21. (>>=) Maybe [Char] Maybe [Char] (>>=) func (=<<) func Int Maybe Int Maybe
  • 22. State (>>=) [Char] State [Char] func1 (=<<) func1 (>>=) Int State Int func2 (=<<) func2 MyType State MyType
  • 23. return IO [Char] IO [Char] length return Int IO Int
  • 24. IO [Char] IO [Char] return . length length return Int IO Int
  • 25. (>>=) liftM IO [Char] (>>=) IO [Char] return . length length (=<<) $ return . length return Int IO Int
  • 27. • • • State
  • 28. • Haskell Kleisli triple Monad • Kleisli triple Monad • Kleisli triple liftM ( Monad )

Notas del editor