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.
Q&A
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:
Abstract Fun-sense: a functional perspective on life
Dana Ma
Staff Software EngineerZendesk