3 ms·
All useful languages have monads. It's a pattern that is nearly impossible to avoid. Where Haskell is different than most languages is that it lets you write ge
by TheCoelacanth 11y ago
All useful languages have monads. It's a pattern that is nearly impossible to avoid. Where Haskell is different than most languages is that it lets you write generic code that operates on any monad.
- AnimalMuppet 11y agoMeaning that any language that doesn't have monads, you're defining to not be useful? Or meaning that monad-the-pattern is everywhere, in every even barely useful language, even if there's no explicit monads in the language?
- TheCoelacanth 11y agoThe monad pattern is everywhere, most languages just don't explicitly recognize it. Any non-trivial program will include many different monads; they just won't be recognized as such in most languages. For instance in C#, there is a monad with bind=?? and return=no-op (similar in use to the Maybe monad in Haskell). There's another monad with bind=; and return=no-op (similar in use to the IO monad in Haskell). C# just doesn't explicitly recognize those as monads.
- ch 11y agoI like this comment because it helps illustrate the subtlety of monads as they apply to programming. I think mode C# programmers would likely think of ';' and '??' as syntax, and who is thinking of 'no-op' as anything!? But if you were in haskell this would not be syntax, but just functions on an instance of the Monad type class. Haskell could easily add some sugar to make these constructs syntax as well, but it would just be sugar -- and that is where the power, and confusion I think arises when most programmers think about monads.
- a3n 11y ago"It's a pattern." "All useful languages have monads ... nearly impossible to avoid." So here's a post on Python (hopefully useful) and monads, it appears to be implementing a pattern, although I don't think I would have ever stumbled across it naturally. http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax.html http://www.valuedlessons.com/2008/01/monads-in-python-with-n... And here's a library implementing monads and other stuff: https://pypi.python.org/pypi/PyMonad/ https://pypi.python.org/pypi/PyMonad/ It still looks like I'm going to have to try using them before I can figure out if it's worth trying to use them.