Collections, text and laziness
These fourteen lessons collect the containers and the text types of Haskell, and then the laziness that makes them cheap: Data.Map and Data.Set, an IORef, an array, Data.Text and ByteString. A thunk and an infinite list follow, then seq and the bang pattern, a space leak read in +RTS -s, and the formatting and the arguments of a program.
056
Data.Map
fromList, lookup, insert, adjust, toList, the cost of each
Open
057
Data.Set
fromList, member, union, intersection, difference, a visited set
Open
058
IORef
newIORef, readIORef, writeIORef, modifyIORef', a counter across calls
Open
059
Arrays
Data.Array, listArray, (!), bounds, //, an immutable lookup table
Open
060
Data.Text
pack and unpack, splitOn, toUpper, Text against String, the API to reach for
Open
061
ByteString
pack, unpack, hPut, length in bytes, a file copied byte for byte
Open
062
Laziness and infinite lists
a thunk, take from an infinite list, cycle, repeat, what is evaluated when
Open
063
seq, $! and bang patterns
seq, $!, BangPatterns, deepseq, a fold that stops building thunks
Open
064
Space leaks and +RTS -s
foldl against foldl', +RTS -s with real numbers, the maximum residency line
Open
065
Random numbers without the random package
a hand-written linear congruential generator, a range, why random is not here
Open
066
Formatting output
Text.Printf, showFFloat, a padded column, a report
Open
067
Arguments and exit codes
getArgs, exitWith, exitFailure, a usage message, a bad argument
Open
068
Modules and exports
module X (a, B (..)) where, export lists, import qualified, hiding, re-exporting
Open
069
A program in several modules
a library module, a main module, ghc Main.hs building both, the artefact names
Open