240

The lightning talk version of this talk. July 19, 2014

## Transcript

Tejas Dinkar
Nilenso Software

• Hi, I’m Tejas
• Nilenso: Partner
• github: gja

3. If you think you understand Monads,

4. This talk is inaccurate and will
make a mathematician cry

• Programmable Semicolons
• Used to hide plumbing away from you
• Monads are just monoids in the category of
endofunctors

6. Values
Value

Value
Box

• return takes a value and puts it in a box
• bind takes a box & function, and returns a box
with f(value)

9. Some math
(√4) + 5

10. Some math
(√4) + 5
3 or 7!

11. Value
4



13. return
def m_return(x)
[x]
end
# m_r(4) => 

14. Square Root fn
def sqrt(x)
s = Math.sqrt(x)
[s, -s]
end
# sqrt(4) => [2, -2]

15. Bind Function
x = m_return(4)
y = ?????(x) { |p|
sqrt(p)
}
# I want [-2, 2]

16. Bind Function
x = m_return(4)
y = x.flat_map {|p|
sqrt(p)
}
# y => [2, -2]

17. Increment Fn
def inc_5(x)
[x + 5]
end
# inc_5(1) => 

18. Putting it together
m_return(4).
flat_map {|p| sqrt(p)}.
flat_map {|p| inc_5(p)}
# => [3, 7]

19. You have invented the