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
330
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
10分でわかるfreee エンジニア向け会社説明資料
freee
18
520k
いろんなものと両立する Kaggleの向き合い方
go5paopao
2
920
End of Barrel Files: New Modularization Techniques with Sheriff
rainerhahnekamp
0
270
Platform Engineering ことはじめ
oracle4engineer
PRO
8
760
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
0
920
SREの前に
nwiizo
11
2.4k
コンテナのトラブルシューティング目線から AWS SAW についてしゃべってみる
kazzpapa3
1
120
Microsoft Intune アプリのトラブルシューティング
sophiakunii
1
360
フロントエンド メタフレームワーク 選定の際に考えたこと
yuppeeng
0
580
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
1
190
AI機能の開発運用のリアルと今後のリアル
akiroom
0
230
フルカイテン株式会社 採用資料
fullkaiten
0
39k
Featured
See All Featured
Six Lessons from altMBA
skipperchong
26
3.5k
Facilitating Awesome Meetings
lara
49
6.1k
KATA
mclloyd
29
14k
What's new in Ruby 2.0
geeforr
343
31k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.8k
Being A Developer After 40
akosma
86
590k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
RailsConf 2023
tenderlove
29
890
Designing for Performance
lara
604
68k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
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