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 knowing it)
Search
Tejas Dinkar
July 19, 2014
Technology
1
300
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
88
Progressive Web Apps In Clojure(Script)
gja
4
2.2k
Monads you've already put in production (without knowing it)
gja
1
1k
Native Extensions Served 3 Ways
gja
0
320
Other Decks in Technology
See All in Technology
よく聞くけど使ったことないソフトウェアNo.1 KafkaとSnowflake
foursue
4
340
Postman v10リリース後を振り返る / Looking back at Postman v10 after release
yokawasa
1
150
2024/4/26 コンピュータ歴史博物館解説告知
toshi_atsumi
0
220
SPI原点回帰論:事業課題とFour Keysの結節点を見出す実践的ソフトウェアプロセス改善 / DevOpsDays Tokyo 2024
visional_engineering_and_design
4
1.9k
アクセス制御にまつわる改善 / Improving access control
itkq
0
510
生産性向上チームの紹介
cybozuinsideout
PRO
1
850
Tableau事例紹介 / Tableau Case Study of Eureka
kazuya_araki_tokyo
1
180
ChatworkのSRE部って実は 半分くらいPlatform Engineering部かもしれない
saramune
0
150
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
110
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.3k
オーナーシップを持つ領域を明確にする
konifar
13
3.1k
本当のAWS基礎
toru_kubota
0
480
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
Documentation Writing (for coders)
carmenintech
60
3.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
The Brand Is Dead. Long Live the Brand.
mthomps
49
28k
Web development in the modern age
philhawksworth
202
10k
Music & Morning Musume
bryan
41
5.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Automating Front-end Workflow
addyosmani
1356
200k
Art, The Web, and Tiny UX
lynnandtonic
289
19k
Ruby is Unlike a Banana
tanoku
96
10k
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