3 ms·
I disagree with the order that this suggests learning stuff. The article recommends first playing around in the functional subset of the language in the REPL, t
by exDM69 15y ago
I disagree with the order that this suggests learning stuff. The article recommends first playing around in the functional subset of the language in the REPL, then learn about theory of monads and finally put it into use with IO.
I feel it's better to jump straight in to IO after doing some basics and definitely before trying to learn deeper theory about monads. The second or third exercise you write should have a little I/O in it, do something like a guess the number or hangman game. I've found that it's also useful to first write it normally using "do" notation and then manually transform it into concrete syntax using ">>=", either mentally or actually writing it out compiling/running. This is a very simple (1 to 2 hour) exercise but should give a pretty good picture of what it's about.
This is a way to avoid the most common pitfall there is in learning Haskell, "not getting monads". There are lots of people who learn the basics of functional Haskell, but they are so afraid of the new concept of monads that they cannot get to writing a real application. I've seen people get stuck in this limbo for years.
Once you know enough I/O to open a file or run a simple loop, the horizons of your Haskell programming projects are vastly extended. If you can read and write files, you can get your hands on more and more interesting data to use for your apps.
Of course, people are different. If you're the kind of person who enjoys reading books about theory (and not the learning-by-doing type), just ignore everything what I just said and go enjoy a book or a wikipedia article about applicative functors, monoids or category theory.
(I don't know pretty much any theory about functors or monoids but it doesn't stop me from writing parsers, compilers and 3d graphics tools using Haskell. Just as not knowing theory about attribute grammars or LALR(1) parsers did not stop me from writing stuff in C.)