モナモナ言うモナド入門.tar.gz
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

モナモナ言うモナド入門.tar.gz

  • 1,834 views
Uploaded on

「モナモナ言うモナド入門」の短縮版。

「モナモナ言うモナド入門」の短縮版。

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,834
On Slideshare
1,702
From Embeds
132
Number of Embeds
5

Actions

Shares
Downloads
8
Comments
0
Likes
4

Embeds 132

http://makopi23.blog.fc2.com 87
http://control.blog.fc2.com 34
https://twitter.com 9
https://si0.twimg.com 1
http://cache.yahoofs.jp 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. モナモナ言う モナド入門.tar.gz 2012-11-18 hiratara
  • 2. 100分で話して来た
  • 3. 超短縮版
  • 4. 話す内容• 抽象化オタクの更なる高みを目指す• 「モナドは自己関手の圏のモノイド」 という雑学
  • 5. 大統一理論2
  • 6. お題Monoid則とMonad則は統一できるか?
  • 7. そのとき Philip Wadlerの脳裏に閃光が走った! ※この話はフィクションです
  • 8. モノイダル圏双関手□と自然同型α、λ、ρがある圏 A B A□B f g f□g A’ B’ A’□B’
  • 9. (モノイダル圏の) モノイド η□M M□η I□M M□M M□I μ λ ρ α M□μ M□M(M□M)□M M□(M□M) M μ□M μ M□M M
  • 10. Monoid a(1) prod (id, mappend’)(a, a), a ((x, y), z) -> (x, (y, z)) a, (a, a) (a, a) prod (mappend’, id) mappend’ mappend’ (a, a) prod (f, g) (x, y) = (f x, g y) a mappend’ = uncurry mappend
  • 11. Monoid a(1) (x <> y) <> z = x <> (y <> z) prod (id, mappend’)(a, a), a ((x, y), z) -> (x, (y, z)) a, (a, a) (a, a) prod (mappend’, id) mappend’ mappend’ (a, a) prod (f, g) (x, y) = (f x, g y) a mappend’ = uncurry mappend
  • 12. Monoid a(2) prod (mempty’, id) prod (id, mempty’)((), a) (a, a) (a, ()) mappend’ snd fst a mempty’ = const mempty
  • 13. Monoid a(2) mempty <> x = x x <> mempty = x prod (mempty’, id) prod (id, mempty’)((), a) (a, a) (a, ()) mappend’ snd fst a mempty’ = const mempty
  • 14. Monoid a(2) mempty <> x = x x <> mempty = x prod (mempty’, id) prod (id, mempty’)((), a) (a, a) (a, ()) mappend’ snd fst a ”集合” mempty’ = const mempty
  • 15. Monoidは 集合圏のモノイド
  • 16. モナド則• 以下と同値 join . fmap join = join . join join . fmap return = join . return = id• 証明は http://ja.wikibooks.org/wiki/Haskell/ %E5%9C%8F%E8%AB%96 を参照
  • 17. Monad m(1) id fmap joinmmma mmma mma join join joinmma ma
  • 18. Monad m(1) join . fmap join = join . join id fmap joinmmma mmma mma join join joinmma ma
  • 19. Monad m(2) return fmap returnma mma ma join id id ma
  • 20. Monad m(2) join . fmap return = id join . return = id return fmap returnma mma ma join id id ma
  • 21. Monad m(2) join . fmap return = id join . return = id return fmap returnma mma ma join id id ma ”自己関手”
  • 22. Monadは自己関手圏のモノイド
  • 23. まとめ• 同じ図で法則をまとめれるのはイイ• 書きかけの検証用ソース https://gist.github.com/4104020