4 ms·
>Anyone who understands monads is on a class of hard drugs. It's so frustrating to hear you say that. Monads are such a simple concept but they're difficult to
by chongli 14y ago
>Anyone who understands monads is on a class of hard drugs.
It's so frustrating to hear you say that. Monads are such a simple concept but they're difficult to explain because they're far more general and abstract than most programming topics. The best explanation I have is that monads are a way of storing some kind of computation with a value. When the user wants access to that value, he uses a monadic operator which forces the monad's computation to be run before returning the value.
- brazzy 14y agoSo basically monads are like a Java object that has a private field and a getter method that has some extra logic. Hey, that's really simple, you're right! duck & runl
- chongli 14y agoNo, objects in Java are more complicated than monads. They include the concepts of identity, mutable state and inheritance; all of which monads lack.
- tel 14y agoAlmost, it's more like an "applyer" method with some extra logic. You're never allowed to get "raw" values out, you can only pass functions inward to modify the value. If you want to get the raw values out (and you almost always do) then you have to add some extra logic to the object above its "monadic" nature. And yeah, it is really, really simple!
- csense 14y agoI'm trying to parse this explanation. What's the difference between a monad and overriding __getattr__ in Python?
- chongli 14y agoApples and oranges. A monad is just an idea; that of storing computations as values. This is useful because these computations can be composed together in a manner not unlike that of a pipeline in shell scripting. Different monads define different ways of composing these computations leading to vastly different semantics. Here's a nice video that explains monads fairly simply: http://www.youtube.com/watch?v=ZhuHCtR3xq8 http://www.youtube.com/watch?v=ZhuHCtR3xq8