3 ms·
Can you recommend a good one? I've read several but still don't get it. And I hardly have time to write code to learn it like people say is necessary.
by sdegutis 10y ago
Can you recommend a good one? I've read several but still don't get it. And I hardly have time to write code to learn it like people say is necessary.
- seagreen 10y agoCan you recommend a good one? ... I hardly have time to write code to learn it like people say is necessary. The _easiest_ way to learn monads is through code (in haskell they're just a tricky typeclass: http://dev.stephendiehl.com/hask/#eightfold-path-to-monad-satori http://dev.stephendiehl.com/hask/#eightfold-path-to-monad-sa...) If you don't want to write code you could learn them like a mathematician from first principles (https://en.wikipedia.org/wiki/Monad_(category_theory) https://en.wikipedia.org/wiki/Monad_(category_theory)), but that seems so much harder to me I'm not sure why you would.
- pron 10y agoPrecious few mathematicians ever learn what monads are...
- Dr_tldr 10y agoIs there a non-haskell resource on monads you could recommend? Anything that starts with "first, learn haskell" is probably not the easiest way, assertions from people who already know haskell notwithstanding.
- seagreen 10y agoGreat point! I found this for python: https://www.stephanboyer.com/post/9/monads-part-1-a-design-pattern https://www.stephanboyer.com/post/9/monads-part-1-a-design-p..., but it definitely focuses more on explanation than practical use. A list of "how to practice with monads in various languages" would be a neat thing to have.
- deleted 10y ago[deleted]
- BellsOnSunday 10y agoI think most people would need to write some code to really grok it, I would anyway. It's a simple enough idea in context, but there's no royal road to understanding. The explanations I know of (all from the Haskell community) are either 1) formal, referring to ideas from category theory, 2) metaphorical, conveying the ideas by intuitions you may already have about burritos or whatever, or 3) pragmatic, focused on how and why you use them in code. I think this last category, pioneered by byorgey's wonderful TypeClassopedia [1], is by far the most useful in teaching people about monads but it depends on observing them yourself. (Ditching the metaphors actually seemed quite radical to me at the time -- I presumed they were necessary because everyone else did.) It builds up from understanding what a Functor is, then the next abstraction up, and so on until Monads seem like an obvious idea. The same approach is used in Learn You a Haskell for Great Good [2] but you need to doing the exercises to follow the book. sigfpe's classic explanation [3] is also by example and goes into a bit more depth. It still contains exercises for the reader though :) [1] https://wiki.haskell.org/Typeclassopedia https://wiki.haskell.org/Typeclassopedia [2] http://learnyouahaskell.com/functors-applicative-functors-and-monoids http://learnyouahaskell.com/functors-applicative-functors-an... [3] http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...
- 0xmohit 10y agoHere's one from LYAH: http://www.learnyouahaskell.com/a-fistful-of-monads http://www.learnyouahaskell.com/a-fistful-of-monads There are a couple of other links here [0] including "Don't fear the Monad" by Brian Beckman. [0] https://github.com/0xmohit/talks https://github.com/0xmohit/talks
- intellectable 10y agoI like how mpj explains it. Monad - FunFunFunction #21 https://www.youtube.com/watch?v=9QveBbn7t_c https://www.youtube.com/watch?v=9QveBbn7t_c Furthermore, the creator of Elm has a fun explanation too. Evan Czaplicki - Let's be mainstream! User focused design in Elm - Curry On https://youtu.be/oYk8CKH7OhE?t=1454 https://youtu.be/oYk8CKH7OhE?t=1454 More serious computer scientist explains monads in the following. Erik Meijer: Functional Programming https://www.youtube.com/watch?v=z0N1aZ6SnBk&feature=youtu.be&t=2569 https://www.youtube.com/watch?v=z0N1aZ6SnBk&feature=youtu.be... and here too https://www.infoq.com/interviews/meijer-monads https://www.infoq.com/interviews/meijer-monads
- amelius 10y agoMy favorite: You could have invented monads (and maybe you already have) [1] [1] https://news.ycombinator.com/item?id=958789 https://news.ycombinator.com/item?id=958789
- RobertKerans 10y agoIf you use JS, if you get how Promises work your probably 90% of the way there; abstracting that pattern out to use in other contexts will probably get you the rest of the way.