SlideShare une entreprise Scribd logo
1  sur  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
                                    )

Contenu connexe

Tendances (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
 

Plus de Masahiro Honma

Plus 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

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 )

Notes de l'éditeur