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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tejas Dinkar
July 19, 2014
Technology
1
420
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
150
Progressive Web Apps In Clojure(Script)
gja
4
2.5k
Monads you've already put in production (without knowing it)
gja
1
1.2k
Native Extensions Served 3 Ways
gja
0
380
Other Decks in Technology
See All in Technology
タスク管理も1on1も、もう「管理」じゃない - KiroとBedrock AgentCoreで変わった“判断の仕事”
yusukeshimizu
0
140
Kubernetesの「隠れメモリ消費」によるNode共倒れと、Request適正化という処方箋
g0xu
0
150
スケーリングを封じられたEC2を救いたい
senseofunity129
0
120
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
300
来期の評価で変えようと思っていること 〜AI時代に変わること・変わらないこと〜
estie
0
110
DMBOKを使ってレバレジーズのデータマネジメントを評価した
leveragestech
0
450
AI時代のオンプレ-クラウドキャリアチェンジ考
yuu0w0yuu
0
600
AgentCoreとLINEを使った飲食店おすすめアプリを作ってみた
yakumo
2
260
Even G2 クイックスタートガイド(日本語版)
vrshinobi1
0
120
Change Calendarで今はOK?を仕組みにする
tommy0124
1
130
「AIエージェントで変わる開発プロセス―レビューボトルネックからの脱却」
lycorptech_jp
PRO
0
180
BFCacheを活用して無限スクロールのUX を改善した話
apple_yagi
0
130
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
440
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Mobile First: as difficult as doing things right
swwweet
225
10k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
We Have a Design System, Now What?
morganepeng
55
8k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
4 Signs Your Business is Dying
shpigford
187
22k
How to Talk to Developers About Accessibility
jct
2
160
Automating Front-end Workflow
addyosmani
1370
200k
Building the Perfect Custom Keyboard
takai
2
720
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
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