- Function composition
- Higher order functions
- Curry/Uncurry
- Referential transparency
- List (map, flatMap, filter, foldL, foldR)
- Option (map, flatMap, filter)
sealed trait Either[+E, +A]
case class Left[+E](value: E) extends Either[E, Nothing]
case class Right[+A](value: A) extends Either[Nothing, A]
- Error handling with additional information
- Monad!
- Coproduct (sum) data type
Coproducts represent when a data type can be one thing or another Products represent when a data type can be many things at once.
Are the following examples of Coproducts or products?
- Case classes
- Sealed trait hierarchies
- Tuples
- HLists (Heterogeneous lists
val demo = 42 :: "Hello" :: User("Julien") :: HNil
) - Option
- map, flatmap, map2, orElse, traverse, sequence