Polymorphic Function Types in Scala 3
summary
Explains concrete Scala 3 changes: adds polymorphic function types that require a polymorphic apply method, implemented as a refinement trait and compiled by erasure that erases to FunctionN (uses FunctionXXL for >22 args) with casts inserted. Shows real uses: Tuple.map preserving element types, Shapeless generic folds for typeclass derivation, type-level sized lists and a Cats Effect example for a safe compute callback. Covers compiler work, SIP-49 experimental status, and proposed ergonomics like type-parameter closure and improved subtyping.
AI-written summary · about
chapters (10)
- 0:00Intro
- 3:15Method references
- 6:49Example usecase
- 10:49Taking a step back
- 13:29Type erasure (2/2)
- 19:30Example 2: Preserving type information
- 25:21Encapsulation
- 29:33Polymorphic eta-expansion (1/2)
- 34:38Idea 2: type parameter clause inference + eta-expansion
- 36:43Better subtyping
related talks
40mPolymorphic Function Types in Scala 3
32mUnderstanding the Type System of Scala 3
45mHow to be polymorphic in Scala
38mThinking in Scala 3 Types
49mType level Programming in Scala
32mAdvanced Features of Scala 3
43mAdding kind-polymorphism to the Scala programming language
51mAdding Kind-polymorphism To The Scala Programming Language
