~/talk

Type Parameter Power-Up! Variance, Bounds, and Inference

Talkat Scala Days New York 2018 · 2018-06-19..06-21· [scala]
links:none on file
slides:none on file

A practical tour of Scala variance and bounds shows when the compiler refuses code (example error covariant type A occurs in contravariant position) and how to fix it: use lower bounds like B >: A to implement a covariant prepend, prefer context bounds and implicits to supply evidence, and implement reusable patterns as a type class (example adder type class for Int and Pair). Examples compile on Scala 2 and stay valid under Scala 3 / Dotty.

AI-written summary · about

  1. 0:00Start
  2. 1:47Motivations
  3. 4:34Liskov Substitution Principle
  4. 5:13Generic Classes
  5. 7:46When Can We Substitute Which Kinds of Machines
  6. 8:26Types of Variants
  7. 10:48Covariance
  8. 24:51Upper or Lower Bound
  9. 28:53Context Bounds
  10. 30:20Type Class Pattern
  11. 34:59Structural Types
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.