Are you curious about functional programming concepts, but daunted by its weird vocabulary? Have you heard of Monads, but struggled to understand what they are? Should you care at all?
In this session I will explain Monads using C# and Java classes. I’ll start with “Why” part, and then will give enough of clear and concise examples that you will be able to bring home and start using in your functional journey.
Functional programming is not complicated, it’s just unfamiliar. Let’s bring some clarity today.
4. “
“
Douglas Crockford,
who found Good Partsin
Javascript
Monads are cursed — once you
understand monads for yourself
you lose the ability to explain them
to others
5. “
“
Tomas Petricek,
The Alan Turing Institute
http://tomasp.net/academic/pa
pers/monads/monads-
programming.pdf
Learning monads and writing a
monad tutorial has also become
an important milestone in
learning about theory of
functional programming
6.
7.
8. // Type annotation
func: TypeA -> TypeB
// Static methods
static class Mapper {
static ClassB func(ClassA a) { ... }
}
// Instance methods
class ClassA {
ClassB func() { ... }
}
9. class Speaker {
Talk nextTalk() { ... }
}
class Talk {
Conference getConference() { ... }
}
class Conference {
City getCity() { ... }
}
10. static City nextTalkCity(Speaker speaker)
{
Talk talk = speaker.nextTalk();
Conference conf = talk.getConference();
City city = conf.getCity();
return city;
}
53. “
“
John De Goes,
who knows what
Monads are
Monads are virtual machines for
expressing sequential, dependent
computation, where the instruction
set of a VM is given by the structure
of the monad's constructors