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

I've only played around with Haskell and NLP (using this guide, actually), but functional languages are a very nice fit for natural language processing, which often involves pipelining text (in the form of arrays or lists of characters) from function to function (tokenization->tagging->chunking->extraction). This fits the functional paradigm very well. I really like using NLTK (Python) but if I were more comfortable in Haskell and if Haskell had better NLP libraries, I'd probably switch to Haskell because it's a natural fit for NLP. But I have to agree with your assessment of monads...I've been learning Haskell on and off for over a year and I'm still shaky on monads. I'm still hoping I will eventually experience that same moment of epiphany with monads that I did with recursions when I first started programming.



What worked for me was going through worked examples with IO, List, Maybe and State. You don't want to just do List, Maybe and Either or you'll associate it with holding onto particular data. You want to use highly disparate things so you can get to the fully abstract understanding.

You might try to understand monoids first, because you already have familiarity with many applications of monoids. The realization "oh, this is just two functions" at the heart of monoids is also what's at the heart of monads, but the applications are different.

Desugaring helps a lot too. I learned by avoiding do-notation, but you can learn do-notation at the same time if you try desugaring as you go, so you can make explicit what's going on under the covers.

It's like math, you have to keep playing with it until you grok it. I find it's good to try out different expressions in ghci, use :t a lot to see what types are coming back, to build intuition.

If you put a few hours into it for a few days in a row, you can probably get to this epiphany in one weekend. The trick is building up enough examples that your brain can generalize it. Nobody's going to learn it by staring at the abstract form and thinking hard--if we did work that way, there would be a lot more use of comonads. That's why it's important to re-type examples. You're not going to be able to write the examples yourself until you understand them, but working through them gives you something to build on, and builds healthy expectations (I'm going to need return here, because the naked value isn't in the monad, etc.)

The epiphany is worth it--but don't count on a monad tutorial to help you much, they're mainly a side-effect of other people having the epiphany.


Thanks so much for your advice -- much appreciated. I've pulled back out my copy of Learn You a Haskell and have just re-read the Haskell wikibook chapter on monads.


No problem. Feel free to drop me an email if you get stuck.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: