Inspired by people, who don't get monads..
I have been stuck with the question of why people don't understand monads. Actually, I saw different kinds of people having different relationships with monads. So I've done a small analysis on why software engineers want to learn monads and from where did they find out about monads.
A lot of people heard this fashionable word "monads" somewhere from somebody smart and their inner geek set up a goal to understand monads to be awesome and cool and to do SWAG things. They are searching for something, and initially they don't have an idea why is it helpful. So the source of their interest is not the necessity to perform the task more efficiently, but the desire to explore something to feel all the advantages and then determine where it might be useful. And when I ask "hey, you are learning monads? Why are you doing this?" I rarely get an answer. It abstractly means, before knowing what monads are they assume that monad is a magic wand producing better results (which is actually true).
I don't mean it's bad if you are one of them - you just get into a tricky situation of understanding some more or less complex for understanding topic. So usually, the process of grasping monads looks like this:
- Google -> Monads
- Reading Wikipedia page, read first three links from search results
- Feeling scary from dozens of mathematical formulas
- Realizing that the search query was wrong
- Google -> What are monads
- Looking through the results
- Finding the definition of monadology by Gottfried Leibniz, getting inspired
- Continue randomly reading posts and articles like "Monads for dummies", "Three steps to understand monads", "Monads in 30 seconds" and so on
- Evaluating whether monads will bring the profit bigger than the effort spent on understanding it
- Google -> Why do I need monads
- Looking through first 3 pages
- Getting convinced that the real benefits of monads will be clear only after understanding monads
- ... DESPAIR.JS
Here is how the process went for the majority of us. The first and mandatory step in understanding monads is literally FAILING TO UNDERSTAND THESE FKN MONADS.
And I won't be writing another monad tutorial to explain monads to you. There are tons of tutorials and at the same time no one single resource, which may suit for everyone.
If you are so strong in your desire to understand them, my only advice will be to look at problems they solve. Look for examples. Maybe monad, division by zero monad, exception handling monad, I/O monad, state monad, async monad... as much as you can. Then you'll understand that monads are there, where you have side effects, and where you want to be concentrated on your code logic and not on handling the way of processing the side effects all the time. So with monads you are focused on your main code and additional actions are performed behind the scenes. And actually, you can even use monads without an understanding how they are built inside, and ... maybe you are using them now not even realizing it :) But these words mean nothing to you until you read your portion if monadic porn.
- Find the initial reason and give a private answer to the question just to yourself: "why I am exploring monads?". The answer like "to be cool and to know something not all programmers know" is pretty OK too :)
- Read some posts on monads. Fail to understand them.
- Find examples. A lof of examples. They'll form the feeling what problems are solved easier. Try to repeat.
- Read those posts from the second point and understand them.
- Determine how can you apply them for your tasks.
Really useful links:
(to be read several times in several iterations)