Higher-Kinded Types
"If they can get you asking the wrong questions, they don't have to worry about answers."
— Thomas Pynchon, Gravity's Rainbow (Proverbs for Paranoids, 3)
The right question is not "how do I map over this List?" or "how do I map over this Optional?" The right question is "how do I map over any container?" Java cannot ask it directly, because a type parameter cannot stand for a container that still waits for its element type. This group is about the encoding that lets Higher-Kinded-J ask it anyway.
Read this group when you want the reasons and the mechanics behind the encoding, or when you add a type of your own. The Ship pages in the Chapter Contents are enough to write code that works for any container, so you can skip the group until then.
Pages in this group
- Why Higher-Kinded Types?: What a higher-kinded type is, and why Java needs an encoding for one
- Type Arity: How a witness declares how many type arguments its container still needs
- Lifting the Hood: One call traced through the encoding, step by step
- Adding Your Own Type: A witness, a helper and an instance for a type of your own, the laws that prove them, and a Path
The Foundations FAQ answers the design questions this group raises, such as why Kind has two type parameters, and what widen and narrow cost.
Previous: Check Your Understanding Next: Why Higher-Kinded Types?