I share the experience with OOP, it took me a lot of "this pen is an object, it has a method write() and an attribute color" example for me to finally learn it.
Considering monads, I have yet to step into FP for that sole reason, some concepts look real hard.
I feel with monads experience using them in a variety of ways might be more useful than reading about it. My explanation of them would be "they're a reification of computation", which is totally useless unless you've already spent a bit of time with them practically.
Monads aren’t nearly as complicated as people make it seem. It’s literally just a generic interface. Kind of like how you can have array.map, linkedList.map, or promise.map... all those types have a sort of common interface. Those are all “functors”. Monads are the same kind of thing, except in addition to map they have flatmap, which is basically just a different version of map which flattens nested results. This allows certain operations to be easily “chainable”. And that’s pretty much it.
Boom - monads!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I share the experience with OOP, it took me a lot of "this pen is an object, it has a method write() and an attribute color" example for me to finally learn it.
Considering monads, I have yet to step into FP for that sole reason, some concepts look real hard.
I feel with monads experience using them in a variety of ways might be more useful than reading about it. My explanation of them would be "they're a reification of computation", which is totally useless unless you've already spent a bit of time with them practically.
Makes sense, oftentimes some concepts only "click" for me after a few weeks applying it naively.
GraphQL is a recent example, I was weeks into a project when I finally realized: "Oh, THAT'S why it is better than REST in this situation".
Monads aren’t nearly as complicated as people make it seem. It’s literally just a generic interface. Kind of like how you can have
array.map
,linkedList.map
, orpromise.map
... all those types have a sort of common interface. Those are all “functors”. Monads are the same kind of thing, except in addition tomap
they haveflatmap
, which is basically just a different version ofmap
which flattens nested results. This allows certain operations to be easily “chainable”. And that’s pretty much it.Boom - monads!