Hacker News new | past | comments | ask | show | jobs | submit login

I am always curious why monad is important in functional language, isn't it accurate to say that monad is just a wrapper class?



In my opinion they're important to pure functional languages (like Haskell) because they're the abstraction that IO is isolated into (IO doesn't require monads, and monads don't always mean that IO is happening, but that's the abstraction they chose).

The monadic pattern is just extremely common (and desirable), here's what the wiki (https://wiki.haskell.org/Monad) says:

> Monads in Haskell can be thought of as composable computation descriptions. The essence of monad is thus separation of composition timeline from the composed computation's execution timeline, as well as the ability of computation to implicitly carry extra data, as pertaining to the computation itself, in addition to its one (hence the name) output, that it will produce when run (or queried, or called upon). This lends monads to supplementing pure calculations with features like I/O, common environment or state, etc.

If I were to try and paraphrase that, it's because it is such a good abstraction for all the things you have to do that aren't as simple as pure functions. In other languages, just about any function can do anything, so they're understandably less important




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: