[a]
s which it uses to produce multiple x
s.
-- F = (b -> .)
-- pick x = a
-- ((a -> a) -> (b -> a) -> (b -> a)
-- Nat(Hom(a, -), F) ~= F a
-- type Hom a b = (a -> b)
-- c -> Hom (c, -)
-- a, b. arrows ∈ Hom (a, b)
-- Hom (a, -), Hom(b, -). arrows ∈ Nat Hom (a, -) Hom(b, -)
--
-- a, b. arrows ∈ Hom (a, b)
-- Hom (-, a), Hom(-, b). arrows ∈ Nat Hom (-, a) Hom(-, b)
contrayo :: Nat (Hom a) (Hom b) -> Hom b a
contrayo :: (forall x. (a -> x) -> (b -> x)) -> (b -> a)
contrayo f = f id
contrayo' :: (b -> a) -> (forall x. (a -> x) -> (b -> x))
contrayo' b2a = \a2x -> a2x . b2a
When we specialize Yoneda to b -> -
, we are led to the idea
that a continuation of the form (a -> x) -> (b -> x)
must contain
plumbing to turn b
s into a
s: ie, it must contain a function b -> a
.
-- F = id .
type Id x = x
-- Nat(Hom(a, -), Id - ) ~= Id a
-- Nat(forall x. (a -> x), Id x) ~= Id a
-- Nat(forall x. (a -> x) -> x) ~= a
idyo :: (forall x. (a -> x) -> x) -> a
idyo k = k id
idyo' :: a -> (forall x. (a -> x) -> x)
idyo' a = \k -> k a
specializing to id
recovers usual continuations.
In total, Yoneda tells us that from every enriched continuation
ContF a g = Nat (Hom a) g = forall x. (a -> x) -> g x
,
we can recover a g a
. Hence, there is a bijection between g a
and
ContF a g
§ Yoneda embedding
The yoneda embedding follows from the lemma. The lemma tells us that Nat(Hom(a, -), F) ~= F(a)
.
Pick F = Hom(b, -)
. This gives Nat(Hom(b, -), Hom(a, -)) ~= Hom(b, a)
Thus, if
we consider the mapping C -> [C, Set]
given by sending a
to F(a)
,
we also preseve the Hom
sets as natural transformations, since Hom(b, a)
is isomorphic
to Nat(Hom(b, -), Hom(a, -))
. Thus, we get a full and faithful embedding of the original category
into the Hom
category.