Presented at: Open Source South Carolina, 8/14/19
Presented by: Dean Hallman, CTO @ Foresight Data Systems
Abstract: This talk will present a simplified understanding of Monads, as well as key constructs that build upon them, like Promises, Railway-Oriented Programming and Functional Reactive Programming.
8. F1 F2 F3 F4 F5 F6 F7 F8
V1 V2 V3 V4 V5 V6 V7
Vi
Vo
M M M M M M M
M
Cross-Functional State
NULL
Monadic Functional Programming:
The “Maybe Monad”
X X X
10. The Rise of Inversion Of Control:
MTS, EJB & Transactional COM+
11. Inversion of Control &
Aspect-Oriented Programming
Main() Library
Main()
IoC Container
Before 2000 After 2000
Your Code Your CodeLibrary
PRE
POST
Event
12. Inversion of Control &
Aspect-Oriented Programming
Main() Library
Main()
IoC Container
Before 2000 After 2000
Your Code Your CodeLibrary
PRE
POST
Event
13. Inversion of Control &
Aspect-Oriented Programming
Main() Library
Main()
IoC Container
Before 2000 After 2000
Your Code Your CodeLibrary
PRE
POST
Event
F1F2F3F4F8
V1V2V3V4
ViVo
14. f f f f f f f f
V1 V2 V3 V4 V5 V6 V7
Vi
Vo
Super-Monadic Functional Programming
Run Time
Declaration
Time
.g1 .g2 .g3 .g4 .g5 .g6 .g7 .g8
Mf
Pipeline
Describe
Mf Mf Mf Mf Mf Mf Mf
15. F1 F2 F3 F4 F5 F6 F7 F8
V1 V2 V3 V4 V5 V6 V7
Vi
Vo
Monadic Functional Programming
M M M M M M M
M
16. The Monad Laws & Interface
• Left identity: return a >>= f ≡ f a
• Right identity: m >>= return ≡ m
if we take a value, put it in a default context with return and
then feed it to a function by using >>=, it’s the same as
just taking the value and applying the function to it.
if we have a monadic value and we use >>= to feed it
to return, the result is our original monadic value.
• Associativity: (m >>= f) >>= g ≡ m >>= (x -> f x >>= g)
when we have a chain of monadic function applications
with >>=, it shouldn’t matter how they’re nested.
• Required:
• unit
• bind
• Optional:
• of
• flatMap
• flatten, join
26. Monadic FP Complexity
◦ Learning Curve for the more advanced concepts
◦ Monadic lensing etc.
27. compose
F(x) F(x) F(x) F(x) F(x)
d
estack f
g
h
i
j
a
b
c
input
stack
stack
stack stack
stack
k
l
output
B, doc
Parameter Hiding & Monadic Lensing
28. F1 F2 F3 F4 F5 F6 F7 F8
V1 V2 V3 V4 V5 V6 V7
Vi
Vo
Monadic Functional Programming
M M M M M M M
M
Cross-Functional State
Surender
Thread
Surender
Thread
By-Value / Containment Monads
Co-propagation
Utilizing OO and FP
Returning this
By-Value / Containment Monads
Value VS State
Co-propagation of Value & State
Monads are a way of avoiding side-effects, by converting cross-functional state into return values