Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Lightning - Monads you already use (without kno...
Search
Tejas Dinkar
July 19, 2014
Technology
1
320
Lightning - Monads you already use (without knowing it)
The lightning talk version of this talk.
Tejas Dinkar
July 19, 2014
Tweet
Share
More Decks by Tejas Dinkar
See All by Tejas Dinkar
Quick Wins for Page Speed
gja
0
100
Progressive Web Apps In Clojure(Script)
gja
4
2.3k
Monads you've already put in production (without knowing it)
gja
1
1.1k
Native Extensions Served 3 Ways
gja
0
330
Other Decks in Technology
See All in Technology
Developer Experienceを向上させる基盤づくりの取り組み事例集
coconala_engineer
0
150
内製化を目指す事業会社が、システム開発会社と共に進める「開発生産性改善」の取り組み事例 #devsumi
yuwji
0
100
テスト”ケース”駆動開発 で手戻りをなくそう
ryohma0510
0
320
ロリポップ! for Gamersを支えるインフラ/lolipop for gamers infrastructure
takumakume
0
130
プロダクトエンジニアを支えるための開発生産性向上施策
tsukakei
0
140
OCI で始める!! Red Hat OpenShift / Get Started OpenShift on OCI
oracle4engineer
PRO
1
180
言葉は感情の近似値である。その感情と言葉の誤差を最小化しよう ~コミュニケーションにおけるアナログ/デジタル変換の課題に立ち向かう~
nktamago
0
220
なぜクラウドサービスで Web コンソールを提供するのか
shuta13
4
2k
エンジニア視点で見る、 組織で運用されるデザインシステムにするには
shunya078
1
310
ナレッジグラフとLLMの相互利用
koujikozaki
0
420
App Router を実プロダクトで採用して見えてきた勘所をちょっとだけ紹介
marokanatani
1
930
事前準備が肝!AI活用のための業務改革
layerx
PRO
1
380
Featured
See All Featured
Become a Pro
speakerdeck
PRO
22
4.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
25
3.9k
Ruby is Unlike a Banana
tanoku
96
11k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
48
2.8k
Facilitating Awesome Meetings
lara
49
5.9k
Producing Creativity
orderedlist
PRO
340
39k
A better future with KSS
kneath
235
17k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
278
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
29
2.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
1
52
Transcript
Monads you’ve already put in prod Tejas Dinkar Nilenso Software
about.me • Hi, I’m Tejas • Nilenso: Partner • twitter:
tdinkar • github: gja
If you think you understand Monads, you don't understand Monads.
This talk is inaccurate and will make a mathematician cry
Monads • Programmable Semicolons • Used to hide plumbing away
from you • Monads are just monoids in the category of endofunctors
None
Values Value
Monads Value Box
Monads • Monads define two functions • return takes a
value and puts it in a box • bind takes a box & function, and returns a box with f(value)
Some math (√4) + 5
Some math (√4) + 5 3 or 7!
Value 4
Monad [4]
return def m_return(x) [x] end # m_r(4) => [4]
Square Root fn def sqrt(x) s = Math.sqrt(x) [s, -s]
end # sqrt(4) => [2, -2]
Bind Function x = m_return(4) y = ?????(x) { |p|
sqrt(p) } # I want [-2, 2]
Bind Function x = m_return(4) y = x.flat_map {|p| sqrt(p)
} # y => [2, -2]
Increment Fn def inc_5(x) [x + 5] end # inc_5(1)
=> [6]
Putting it together m_return(4). flat_map {|p| sqrt(p)}. flat_map {|p| inc_5(p)}
# => [3, 7]
You have invented the List Monad, used to model non-determinism
Congrats