Please log in to watch this conference skillscast.
Everything can be a function if you look at it the right way; we can characterise familiar concepts like sets, lists and even plain values as functions.
Thinking about such basic objects as functions can seem unnecessarily abstract, but it isn’t just an exercise in increasingly intimidating notation! It turns out to be an elegant perspective that allows us to glimpse a more powerful abstraction.
In this talk, we’ll see how playing with this notion leads to the Yoneda Lemma, a key result in category theory. We’ll build up some intuition and motivation for the Yoneda Lemma, and return to the notion of viewing objects as functions to appreciate some of its implications.
Question: So naturality is a condition on functions that preserve identity?
Answer: It’s a condition on a polymorphic function, which captures the intuition that it has to act uniformly on all types.
I think of things that
preserve identity are like a different class
of thing, like functors (which operate on types as well as having
map, but the
map is the thing here that preserves the
identity. There isn’t an equivalent of
map for naturality).
Question: Hard because you showed that the identity was the only thing this polymorphic function could do that would work across all types, therefore anything else would not.
Answer: ah yeah, that’s the only thing the polymorphic function
can do if it has type
T -> T.
Polymorphic/natural functions of more complex type signatures can do other
things, like e.g.
[T]_n -> T can be the function that takes the
first element of a list. Or even
[T]_n -> [T]_n could reverse the
list. they’re both still acting uniformly on all types.
Also --- yes!!! it’s hard.
Question: Ah ok, so naturality on T->T is super restrictive, but more interesting with more complex types, because we’re identifying operations that are truly polymorphic
Answer: yes, exactly! that’s a really great way of putting it
YOU MAY ALSO LIKE:
- Building Rome Every Day - Scaling ML Model Building Infrastructure (SkillsCast recorded in May 2019)
- Haskell eXchange 2022: Novice Track (Online Conference on 7th December 2022)
- Haskell eXchange 2022: Online Conference (Online Conference on 8th - 9th December 2022)
- Haskell: Why and How the External STG Interpreter is Useful (SkillsCast recorded in December 2021)
- Keynote — Haskell: What To Do When Success Can't Be Avoided (SkillsCast recorded in November 2021)