9. Background
• Lambda calculus
• Category Theory
• Categorical properties: identity, composition, and morphisms
(functions)
• Algebraic data types: functors, applicatives, monads
10. Basic Principles
• A function is a mapping from one type (A) to another (B) within the
same category of objects
• f :: A -> B
• Everything is a function
• Functions are the main unit of work
• Functions are first-class citizens
• Functions are of higher-order
• Favor expressions vs statements
• Avoid externally visible side effects
• Avoid mutable state
11. Avoid side effects
• Keep changes from leaking
• If you must, move them to the boundaries of your logic
• Manage effects with declarative, lazy containers (e.g. IO monad)
23. Currying is essential for composition
• Partially evaluate functions
• Never evaluate a function with missing data
• Transform multi-arity in to single-arity functions
• Functional languages use auto-currying + lazy evaluation
28. What are Functors
• Functions are mappings from one object to another
• Functors are mappings from one category to another
• Most common is the endofunctor (same categories)
• Functors define a function named map (fmap)
29. What are Functors
• Functions are mappings from one type to another
• Functors are mappings from one context to another
• Most common is the endofunctor (same context)
• Functors define a function named map (fmap)
35. What is an Applicative (functor)
• Functor with extra laws and operations
• Not just wrap values, wrap functions too!
• Implements the Apply interface: ap
40. What is a monad
• Functors apply a function to a wrapped value
• Applicatives apply a wrapped function to a wrapped value
• Monads apply a function that returns a wrapped value to another
wrapped value. Enter flatMap (bind, chain)