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
360
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
110
Progressive Web Apps In Clojure(Script)
gja
4
2.4k
Monads you've already put in production (without knowing it)
gja
1
1.1k
Native Extensions Served 3 Ways
gja
0
340
Other Decks in Technology
See All in Technology
大規模アジャイルフレームワークから学ぶエンジニアマネジメントの本質
staka121
PRO
3
1.7k
サバイバルモード下でのエンジニアリングマネジメント
konifar
21
7.3k
プルリクエストレビューを終わらせるためのチーム体制 / The Team for Completing Pull Request Reviews
nekonenene
3
1.4k
AIエージェント入門
minorun365
PRO
33
20k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
540
MIMEと文字コードの闇
hirachan
2
1.5k
Two Blades, One Journey: Engineering While Managing
ohbarye
4
2.7k
困難を「一般解」で解く
fujiwara3
8
2.3k
貧民的プログラミングのすすめ
kakehashi
PRO
1
110
Oracle Database Technology Night #87-1 : Exadata Database Service on Exascale Infrastructure(ExaDB-XS)サービス詳細
oracle4engineer
PRO
1
220
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
380
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership, regardless of position
madoxten
13
6.7k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
Building Your Own Lightsaber
phodgson
104
6.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
The Invisible Side of Design
smashingmag
299
50k
How to Think Like a Performance Engineer
csswizardry
22
1.4k
Statistics for Hackers
jakevdp
797
220k
Navigating Team Friction
lara
183
15k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
660
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
134
33k
BBQ
matthewcrist
87
9.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
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