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
75
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
85
AlertForViber_20171207
momotaro98
0
270
アウトプット駆動スキルアップ
momotaro98
1
100
マイクロサービスの概要と構築 統合編
momotaro98
0
120
Other Decks in Technology
See All in Technology
Datadog の学び方 - あるいは、オブザーバビリティを学ぶとは何か
mananyuki
1
440
[2026 Oracle Technical Deep Dive] VMwareワークロードのOCI移行実践ガイド - OCVSでの継続利用からOCIコンピュートへの移行まで (2026年9月17日開催)
oracle4engineer
PRO
0
120
自律型 AI をセキュアに実装!Gemini と MIG で作る動的コード実行環境
recruitengineers
PRO
1
210
SDDの運用にめげずに向き合った話
sansantech
PRO
0
130
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
130
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
120
[2026 Oracle Technical Deep Dive] AI時代のデータベース基盤をどう選ぶ? Exadata Database Serviceの選択肢と使い分け (2026年9月17日開催)
oracle4engineer
PRO
0
220
20260930_Gemma4_Hands-on
tsho
0
220
AgentCoreで実践するハーネスエンジニアリング
yakumo
1
280
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
290
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
2
380
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
300
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
390
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Skip the Path - Find Your Career Trail
mkilby
1
240
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
350
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
720
WCS-LA-2024
lcolladotor
0
840
Fireside Chat
paigeccino
43
4k
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