Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
State

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

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

[Char] -> [Char]                      ...
id

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

[Char] → [Char]                       ...
(2)
:


                Maybe

[Char]                          Maybe [Char]

                        Maybe

       length     ...
[]

[Char]                 [ [Char] ]

                  []

    length                    liftM length

             []

...
[]                           [Char]


              []

[Char]                  [ [Char] ]

                   []

     le...
liftM                     Maybe


                     []

        [Char]                    [ [Char] ]

                 ...
(3) return
:
           Maybe


           return
[Char]              Maybe [Char]




           return
 Int                 Maybe I...
[]



         return
[Char]            [ [Char] ]




         return
 Int                [ Int ]
return
            State



            return
 [Char]                         State [Char]
            return
  Bool     ...
(4) (>>=)
Maybe




[Char]                  Maybe [Char]


                 func



 Int                     Maybe Int
         Maybe
(>>=)
              Maybe




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



              ...
State



                 (>>=)
[Char]                   State [Char]
          func1
                                 (=<...
return

                  IO




   [Char]                  IO [Char]



         length

                  return
     In...
IO




[Char]                   IO [Char]

            return . length
   length

            return
 Int                 ...
(>>=)                         liftM

                 IO




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

                 ret...
•

• return

• (>>=)
•


•

•   State
• Haskell          Kleisli triple
                   Monad

• Kleisli triple        Monad



• Kleisli triple         lift...
Upcoming SlideShare
Loading in …5
×

Stateモナドの解説 前編

2,361 views

Published on

Published in: Technology, Education
  • Be the first to comment

Stateモナドの解説 前編

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

×