Reading group: Learn You a Haskell: Part Four

This week, on Friday, March 7, we’ll cover:

  • Functor, fmap, Maybe, and Either
  • Input/Output

This is the second half of chapter 7 and all of chapter 8.

This week, we covered the following:

  • Functor
  • fmap
  • Maybe
  • Either
  • Kinds
  • Side effects
  • Separating pure from impure
  • ghc
  • runhaskell
  • empty tuple, aka “unit”
  • IO, IO (), IO String
  • putStr, putStrLn, getLine, putChar, print
  • do syntax
  • let in do syntax
  • <-, the “from” operator
  • null, return, when
  • sequence, mapM, mapM_, forever, forM

Functors are values that can be mapped over. I find it helpful to think of values which have a context. For examples, a list is a value where the context is that there may be more than one value. Maybe is a value where the context is that the value may not exist.

You can use the runhaskell command to run .hs files directly instead of compiling them with ghc as the book recommends.

We discussed that let is different in do syntax than it is in normal functions:

  • Within do syntax, you can use more than one let interspersed with other lines.
  • Outside do syntax, you can only have one let at the beginning of the expression.

We discussed the null, return, and when functions, pointing out that they are functions and not language keywords, and that they have nothing to do with their counterparts from Ruby, Java, and other languages.

I also found these links which I find helpful for knowing how to pronounce certain Haskell operators when discussing code out loud:

http://www.haskell.org/haskellwiki/Pronunciation