Data vs Control: a tale of two functors
summary
Argues that Haskell has two distinct functor flavors and uses GHC’s linear types to expose them: a data functor (maps over stored values, e.g. list, fixed-size vectors, Traversable) and a control functor (supports do-notation/strength, e.g. monads, IO, state). Presents concrete type signatures, shows why only a linearly consumed closure may capture linear variables, compares ziplist vs cartesian list applicatives, and reports a working linear-base library prototype that encodes the two classes and typechecks the examples.
AI-written summary · about
chapters (26)
- 0:00Introduction and welcome
- 1:10Data and control in Haskell
- 2:55Functor and Traversable as data
- 5:03Applicative and Monad as control
- 6:09Lists: both data and control
- 8:19Applicative duality in lists
- 8:40Lambda calculus and monads
- 10:11Vectors: applicative and traversable
- 12:15Distinguishing data and control
- 13:21Linear types as a prism
- 14:02What are linear types?
- 16:34Interactive linear type examples
- 20:36Linear map and functor types
- 24:16Closures and linearity
- 26:00Key rule: linearly consumed closures
- 26:44Monad bind and linearity
- 29:16Data vs control functors
- 31:31Data and control applicatives
- 33:17Examples of functors
- 36:07Data monads and control monads
- 37:28List comprehensions and control
- 39:18General framework and Moggi
- 41:28Strength and strong monads
- 44:19Strong functors and control
- 45:44Enriched category theory
- 46:49Summary and conclusions
