Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Haskell-Rinko-11
Search
Shintaro Ikeda
May 14, 2019
Technology
74
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Haskell-Rinko-11
Presentation for
http://learnyouahaskell.com/a-fistful-of-monads
Shintaro Ikeda
May 14, 2019
More Decks by Shintaro Ikeda
See All by Shintaro Ikeda
Difference between Swagger and OpenAPI
momotaro98
0
200
習慣的にやりたいことを手助けしてくれるLINEボットを作った話
momotaro98
0
84
AlertForViber_20171207
momotaro98
0
270
アウトプット駆動スキルアップ
momotaro98
1
100
マイクロサービスの概要と構築 統合編
momotaro98
0
120
Other Decks in Technology
See All in Technology
20260929_AmazonGuardDutyの検出通知メールにAWS DevOpsAgentの調査結果を追加する
yhana
1
360
20260930_Gemma4_Hands-on
tsho
0
110
Antigravity SDK for the Java Developer
glaforge
0
230
Making AI Agents Safe and Fast- Jev, Obsidian, and the Meta-Harness
x5gtrn
PRO
0
160
Coil3を内部実装から読み解く~キャッシュ戦略とAVIF画像の描画〜/nikkei-tech-talk50
nikkei_engineer_recruiting
0
140
Claude起点の仕様駆動開発
tanakaseiya
0
110
Harness Engineering on Rails
joelq
0
750
PQC移行の今 -- IETF からみた現在地
satokan
4
620
【Findyテック文化祭ワークショップ】新卒エンジニア&採用担当と作る、 なりたい姿と今やるべき一歩
dip_tech
PRO
0
150
猫でもわかるKiro Web
kentapapa
1
150
C#コードの結合を可視化する Roslyn解析による設計改善と リファクタリング判断
dora56
0
970
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
660
Featured
See All Featured
Building AI with AI
inesmontani
PRO
1
1.3k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
340
Embracing the Ebb and Flow
colly
88
5.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building Adaptive Systems
keathley
44
3.2k
The Cult of Friendly URLs
andyhume
79
7k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
700
Speed Design
sergeychernyshev
33
2.1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
410
Transcript
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 1/16 CHAPTER 12 - A FISTFUL OF
MONADS CHAPTER 12 - A FISTFUL OF MONADS モナドがいっぱい モナドがいっぱい 発表者: 池田 伸太郎 2019 年5 月14 日
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 2/16 Functor → Applicative Functor → Monad
→ → モナドはアプリカティブファンクターの特徴も兼 ねた強化版
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 3/16 復習 Functor もApplicative Functor もある文脈( 箱とも言
っている) を表現する型クラス。 Eq, Ord 型クラスとは異なり、1 つ分の型引数を取 る型コンストラクタが利用対象。 , , とかはApplicative Functor だし Monad でもある。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 4/16 復習 - You Maybe remember... ああ、確かにアプリカティブ則が成り立っている
ようだな、と納得することができますね。 定義
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 5/16 復習 - リスト ああ、確かに(ry
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 6/16 モナドくんの願い モナドくんの願い 普通の値a を取って文脈付きの値を返す関数に、文 脈付きの値m a
を渡したい 言い換えると以下の関数が欲しい 関数 はバインド(bind) と呼ばれる。 モナドは をサポートするアプリカティブファ ンクターである。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 7/16 モナドくん モナドくん
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 8/16 Haskell の歴史的背景によりMonad 定義には Applicative の型クラス制約がない。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 9/16 【綱渡りの問題】 養魚場で働くピエールが休暇を取り綱渡りに挑 戦。バランス棒に鳥が止まりに来るんです。鳥た ちはちょっと休んでまたどこかへ飛んでいく。 棒の左右に止まった鳥の差が3 以内ならば、ピエー
ルはバランスが取れるがそうでないならバランス を崩して落ちてしまう。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 10/16 でも はPole 型しかとれない! と合成して書きた いときはどうすれば良い?
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 11/16 は を文脈付きのまま扱うことができ る。 このように文脈の値どうしを相互作用させること はアプリカティブファンクターにはできないこと でありモナドならば実現できる。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 12/16 もし をモナドとして扱っていなかったら... このような巨大で汚いコードを でモナド適用 の連鎖で書き直すのは、Maybe モナド布教コード
の定番。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 13/16 do 記法 いつ を使い、いつdo 記法を使うか、選択はあ なた次第です。
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 14/16 リスト([]) はモナド。リストをモナドとしての側面 を使うことで、非決定性を伴うコードをきれいに 読みやすくすることができる。 リストからすべてのパターンを尽くして非決定的 値を最終的に返す。
非決定性 性質 扱 定義
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 15/16 実は、リスト内包表記はリストモナドの糖衣構文 であった!リスト内包表記もdo 記法も、内部では を使った非決定性計算に変換される。 記法 書
2019/5/13 reveal.js file:///Users/shintaro/Dropbox/Presentation/RakutenDoki_Rinko_Haskell_11/my-reveal.js/index.html 16/16 モナド則 モナド則 【左恒等性と右恒等性】 => いずれも が通常値をモナド値に最小限な
単位で返すことを保証する法則 【結合法則】 => モナド値をモナド関数らに食わせるとき、入れ 子の順序は関係なく関数自体の意味のみが結果に 反映されるよ 詳しくは で! WEB