0
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モナドの解説 前編

1,824

Published on

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,824
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
48
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide




























  • Transcript of "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 )
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×