Types and data
A type in Haskell is built from constructors, and the data declarations of this part are the sum, the product, the record and the recursive tree. The fourteen lessons cover data and newtype, Maybe and Either, and then type classes: a class, its instances, the deriving that writes them, and the three classes every later effect is built on, Functor, Applicative and Monad.
3.1
data and algebraic data types
data, constructors, deriving Show, a value of your own type
Open
3.2
Sum types and exhaustive matching
several constructors, a match that must cover them, -Wincomplete-patterns
Open
3.3
Product types
a constructor with several fields, positional access, data against tuples
Open
3.4
Records
field names, construction, update syntax, accessors, Show
Open
3.5
newtype and type synonyms
type for a synonym, newtype for a distinct type, deriving through it
Open
3.6
Recursive data: trees
a binary search tree, insert, toList, the fold over it
Open
3.7
Maybe and the missing value
Just and Nothing, fromMaybe, mapMaybe, case on a lookup
Open
3.8
Either and recoverable errors
Left and Right, validation, partitionEithers, the error in the type
Open
3.9
Type classes
a class, its methods, an instance, a constraint in a signature, the dictionary idea
Open
3.10
Instances, deriving and DerivingStrategies
an instance by hand, deriving Eq Ord Show, DerivingStrategies, GeneralizedNewtypeDeriving
Open
3.11
Enum and Bounded
[minBound .. maxBound], succ, pred, toEnum, a custom Enum
Open
3.12
Show, Read and Text.Read
show, read, readMaybe, a parse that may fail, why read alone is unsafe
Open
3.13
Functor and fmap
fmap, <$>, the laws, Maybe, lists and IO as functors
Open
3.14
Applicative
pure, <*>, liftA2, a validation that collects errors
Open