Just like the title says. I've googled, I've read, but I still haven't found a concise, easy-to-understand explanation of what a monad is. I hope someone here will share a valuable insight.<p>Thanks in advance!
Before you try to understand what they are, try to understand why they are important and why each type of monad you come across is important, starting with the Maybe monad, which I think is one of the most obvious.<p>Someone smarter than me feel free to correct me, but my experience has been that every monad I've learned seeks to take a particular imperative or procedural programming idiom, which itself may pop up in several different styles, and "standardizes" how that programming problem is handled by putting it in a special typeclass. This "standardization" is a huge source of power since how the problem is handled becomes predictable, less likely to contain bugs and generally leads to a more composable code.<p>Take the Maybe monad for example. I'm sure that as you've programming you've found yourself constantly checking for an undefined or null argument/parameter value at the beginning of a function. Sometimes people just return false, null or undefined. Other people return errors. Some throw exceptions. The Maybe monad gives you a typeclass that allows some data to be Just the value you want or nothing. Since you have a standard way of having something be undefined and it's encoded in the datatype itself, you never really have to handle undefined values in other functions. Why? Because these other functions that work with the Maybe monad don't really operate on the value directly. Instead they operate on the value via the Maybe monad's fmap function.<p>Check out this post for a good explanation of some monads:<p><a href="http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html" rel="nofollow">http://adit.io/posts/2013-04-17-functors,_applicatives,_and_...</a><p>This too:<p><a href="http://adit.io/posts/2013-06-10-three-useful-monads.html" rel="nofollow">http://adit.io/posts/2013-06-10-three-useful-monads.html</a><p>From now on, whenever you see a new monad, ask yourself what generalizable programming problem or idiom it is trying to encapsulate and why it's important to solve that programming problem. With the case of the Maybe monad I mentioned above, you can read up on a lot of the literature out there explaining why the invention of null was a terrible. C.A.R. Hoare calls it his billion dollar mistake.<p>If you don't understand the problem being solved, understanding the abstraction presented by a particular monad is going to be a lot harder.
Personally I like this tutorial by douglas crockford<p><a href="http://www.yuiblog.com/blog/2012/12/13/yuiconf-2012-talk-douglas-crockford-on-monads-and-gonads-evening-keynote/" rel="nofollow">http://www.yuiblog.com/blog/2012/12/13/yuiconf-2012-talk-dou...</a>
Brian Beckman's explanation might help shed some light on the concept: <a href="http://www.youtube.com/watch?v=ZhuHCtR3xq8" rel="nofollow">http://www.youtube.com/watch?v=ZhuHCtR3xq8</a>