Haskell articles

A couple of very good Haskell articles I have seen recently:

  • Introducing the Monads by Aditya Siram. An great overview which serves to confirm/reinforce things that I have learnt or figured out so far. Tho’ I think uses return where it is unnecessary; for example the first snippet on p.4 should be:
    mport Data.Char
    main :: IO ()
    main = do
         writeFile "test.txt" "a,b,c,d,e"
         x <- readFile "test.txt"
         print (map toUpper x)
    

    IMHO. Into what are we injecting y? Surely if you have an IO String at the first opportunity you would want to ← it to a String so you could play with it in pure code (i.e. toUpper in this case).

    Also I wasn’t aware of this technique, which I will definitely be using:

    import "mtl" Control.Monad.State
    

    Then compile with:

    ghc --make -XPackageImports ...
    

    Since I seem to have both monads-fd and mtl installed. Previously I had been using -hide-package.

  • Monad Transformers Step by Step by Martin Grabmüller. Much more theoretical, I think I probably need to read it a few times to get the most out of it.

Normally I learn a language by just dropping myself in at the deep end and saying right, this program that I need to write anyway, instead of using (language I know) I’ll do it in (new language), God help me. Pascal, MATLAB, FORTRAN, C, C++, Perl, Java, Python, Tcl/Tk… I started in Python using it as I would have used Perl (yuk! but I was young), then before long worked up to HOFs, generators, decorators, etc. Same with Tcl. My early Java looked like C and my early C looked like Pascal.

But that doesn’t work for Haskell or OCaml. I tried it before and had to give up, this time I am being much more methodical about it, getting the foundations in place, and it’s paying off so far.

About Gaius

Jus' a good ol' boy, never meanin' no harm
This entry was posted in Haskell, Random thoughts. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s