Can someone provide an explanation that would make sense to an experienced developer in the OOP world?
Ask HN: What is a monad?
1–10 of 55 posts
Re: Ask HN: What is a monad?
#2http://www.rbjones.com/rbjpub/philos/classics/leibniz/monad....
Re: Ask HN: What is a monad?
#3The monad is the axioms outlined in the article. The applicability of the monad are the logical consequences of its axioms, but it is no more than its axioms.
Happy hacking!
Re: Ask HN: What is a monad?
#4Monads can be implemented in OO languages, like ruby: http://moonbase.rydia.net/mental/writings/programming/monads...
Tony Morris, on of the authors scalaz (which implements monads, among other things, in scala ): http://projects.tmorris.net/public/what-does-monad-mean/arti...
A one that was considered a very good explanation on the topic: http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...
Re: Ask HN: What is a monad?
#5Re: Ask HN: What is a monad?
#6This is a good intro: http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/ba...
Be sure to mentally replace "monad" with "warm fuzzy thing" when reading it and it should make sense.
Re: Ask HN: What is a monad?
#7Re: Ask HN: What is a monad?
#8http://www.it.uu.se/edu/course/homepage/avfunpro/ht10/notes/...
Re: Ask HN: What is a monad?
#9OO is designed to hide the dangerous parts of the world from you. The dangerous parts of the world (or at least some dangerous parts of the world) are encapsulated inside little black boxes with well defined interaction points. If you interact only through those little boxes, you should be safe. For instance, a logger object gives you 1 methods: writeLog (I'll ignore logging levels). The details of actually writing logs are not your business, and you (in principle) don't need to worry about them.
Monads are stricter. A monad puts you into a box and only gives you a few interaction points with the outside world. You can do whatever you want in a monad, but you are never allowed to leave the box. Inside the logger box, you are permitted only pure functions (functions with no side effects) and writeLog.
So basically, in an OO world, code using a logger might call os.unlink("/var/log/myprogram.log"). This would interact in a harmful way with your logging mechanisms. In a monadic world, from inside the logging monad, you are not given access to os.unlink.
Thus, f: a -> Loggable b in the monadic world (where Loggable b is an b living inside the box) is safer than f: (Logger, a) -> b in the OO world.