Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I read the article and I still don't understand what monads are about. This happens every time. There must be something about the Haskell syntax (which has been ages since I used it in college--and I utterly failed to grasp monads then, too) it's very frustrating, I get the rest of functional programming. Apparently I forgot how to read Haskell.


Its not the syntax, its the concept that's hard. I read about 10 different monad tutorials, and it only made things worse. The only thing that made it click was writing code that used them. (Some monadic parser code.)

Seriously, reading monad explanations is like struggling in quicksand of abstraction. Only by making it concrete in working code did I make any progress.

If I had to pick the most tractable monad, I would try the Maybe monad, use it for map lookups in Haskell's Data.Map, since its something you would commonly do with a Python dictionary anyway.


My issue with that approach is that it's hard to know whether you're actually using monads if you don't really understand what they are.


I'm just getting it now. Google for something called Typeclassopedia and read about Functors, and then Applicative functors. Those are much easier to understand right away, and they set the stage for monads. Applicative functors relate to functors in an obvious way (you could probably implement one in terms of the other). Monads relate to applicative functors in a less obvious way, to me anyway, but at least it's analogous enough that it helped a whole lot (particularly that return and pure were the same thing)

I read about the first two on the typeclassopedia page, and was somewhat unsatisfied with its explanation of monads. I then went to Learn You a Haskell's page on all three of these and skipped to monads, and I was happy with it. I bet you could just read about all three on the Learn You page, the guy does a great job.


"Learn you a Haskell for great good" is probably the most approachable book on the subject you can read it online for free.

People who are confused should definitely check it out.


Yes, it is by far the best way to learn what monadic really means. http://learnyouahaskell.com/chapters is the book, but if you already understand basic Haskell syntax, you can start at Chapter 11, Functors: http://learnyouahaskell.com/functors-applicative-functors-an...

Yes, it's a bit long, but it actually works, and, what's more, unlike the vast majority of monad tutorials written by someone who just sort of half figured out the concept half-an-hour ago (but they really didn't), it is also correct. This is one of the major root causes behind people's general inabilities to "understand monads after reading tons of tutorials", the tutorials are not only generally not very good but often wrong and mutually contradictory.


Oh sorry, yes I forgot that they were in two different sections. Definitely read the one about Functors before you get into Monads.


IMO the best intro to monads is You Could Have Invented Monads:

http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...

It starts from concrete examples, lets you write a few exercises, then it shows you the common pattern behind those examples.


Same here. I must have read every article explaining Monads that I saw, but I still have no idea what they are.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: