Hi Everyone,
This is a kind of quick follow up to my FP presentation and comments about how I didn't grasp Ken's advanced presentation on Monads...
With thanks to Oles - for his links to Bartosz Milewski's YouTube presentation on Category Theory;
A category MUST have an identity and its members MUST be composable.
From my presentation I had;
Monads are simply a way to wrap things and provide methods to do operations on the wrapped stuff without having to unwrap them.
In order to have a Monad – it must implement;
* unit
* map &
* flatMap methods.
Previously I just took for granted the list of Must Haves for a Monad : but now I can understand and visualise how monads came to be : they're just a flavour of a category.
Given that a list() is a monad : and lets further imagine we have a list() of numbers: List(1,2,3)
The Unit / identity requirement simply allows us to have an operation that returns our list items without an effect on those items.
If we were to write a List() collection ourselves then we would have a function that returns our list members with a *1 - so as to return the member unchanged;
1 * 1 = 1 (the output is unchanged from the argument provided)
2 * 1 = 2 " "
3 * 1 = 3 " "
And finally, the map and flatMap methods simply allow us to use composition on our List() members.
I still can't read a Wikipedia explanation and imagine how it applies to Scala / Functional Programming... but Bartosz' explanations so far (I am 1/2 way through episode 7 of 20) I have found really digestible.