|
|
|
|
|
by stormbrew
4405 days ago
|
|
Not gonna lie, I was hoping for something funnier when I clicked this, because I find the endless stream of terrible examples and explanations for what a monad is extremely funny. Maybe that makes me a terrible person, I'm not sure. But I think this is a rare useful addition to the corpus on layman understanding of "what is a monad?" Because it goes to an effort to try to destructure the problem and attack it from the angle of "why is a monad useful?", the answer to which, to most people, amounts to "it probably isn't to you right now, but it might be someday." What it really comes down to, though, is that a monad is a way for you to define a program that actually Does Useful Things (like ask questions and act on them and output answers and occasionally tell you you're doing it wrong). You can use a C++ compiler or a ruby interpreter for this, or you can write a program in Haskell that generates one. And if you do the latter, monads are the construct that you build them with. From there you have to explain why there's a benefit to going the roundabout route to useful things, but no one's going to understand them until they understand that basic premise. |
|
The explanation is better than most I've seen, but it also feels a bit too reductive. IO is probably the best way to start understanding monads (futures also helped), but this idea of decorating instructions means you can do things like implement your own exception handling mechanism if need be. Lingual features of this scope usually aren't given to users, excepting a Lisp.
The hard part for me is grappling with how abstract a monad is. To this end, it almost seems easier to observe the uses of them rather than trying to fit them in a box (for now). Every explanation I read on them now sheds a bit more light on them, so it's just a matter of time and persistence.