Monads and effects

The Monad class opens this part of the Haskell course, and every lesson after it is about an effect: input and output, a file, a handle and the exception. The fourteen lessons cover do notation and the laws, Foldable and Traversable, the monoids, and the three transformers a program uses most: State, Reader and Writer. The part ends on a transformer stack and on the time of a measured run.

4.1 Monad and bind >>=, return, the laws, Maybe and lists as monads Open 4.2 do notation do desugared, <-, let, a pattern in do, when Open 4.3 IO and purity IO as a type, getLine, putStrLn, fmap over IO, why main is IO Open 4.4 Files readFile, writeFile, appendFile, withFile, openFile and the handle modes Open 4.5 Standard input and output getContents, interact, hGetLine, hPutStr, buffering, isEOF Open 4.6 Exceptions Control.Exception, try, catch, evaluate, bracket, error against throwIO Open 4.7 Foldable foldMap, foldr over a tree, toList, sum on any Foldable Open 4.8 Traversable traverse, sequenceA, mapM, a validation through a list Open 4.9 Semigroup and Monoid <>, mempty, mconcat, Sum, Product, Any, All, a report monoid Open 4.10 State Control.Monad.State, get, put, modify, runState, a counter Open 4.11 Reader and Writer ask, asks, local, tell, runReader, runWriter Open 4.12 Monad transformers StateT over IO, lift, runStateT, a stack of two monads Open 4.13 Why the monad laws matter left and right identity, associativity, a broken instance and what it breaks Open 4.14 Time and dates getCurrentTime, diffUTCTime, UTCTime, formatTime, a measured duration Open

Lessons