Solutions to the exercises of DaoFP, Chapter 18: DaoFP Chapter 18 Exercises. Index: Map of Content.
Solution 18.1.1
With : . By Yoneda, where is the regular representation — the monoid acting on itself by post-composition. The end becomes with the regular representation, which by the Yoneda corollary in is : the equivariant endomaps of the regular representation are exactly right multiplications by monoid elements. So the monoid is recovered from its category of -sets.
Sources: DaoFP Exercise 18.1.1.
Solution 18.2.1
newtype Adapter a b s t = Ad (s -> a, b -> t)
instance Profunctor (Adapter a b) where
dimap f g (Ad (h, k)) = Ad (h . f, g . k)
fromIsoP :: IsoP s t a b -> (s -> a, b -> t)
fromIsoP pp = let Ad p = pp (Ad (id, id)) in pAdapter a b is a profunctor in s t; feeding the identity adapter Ad (id, id) :: Adapter a b a b to the polymorphic function yields Adapter a b s t, whose contents are the sought pair.
Sources: DaoFP Exercise 18.2.1.
Solution 18.4.1
If , the second hom-set is a singleton and the optic reduces to ; by co-Yoneda-style reasoning this is just up to the residue — a getter (the side is trivial). With the first category and the second terminal, and are pairs and the optic is — the existential lens with all arrows reversed, i.e. a lens in the opposite category.
Sources: DaoFP Exercise 18.4.1.