Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between Coyoneda and free-functors

As I know we can derive functor for free via Coyoneda. But exists some haskell package http://hackage.haskell.org/package/free-functors

And my question, what is difference between Coyoneda and http://hackage.haskell.org/package/free-functors-0.8.1/docs/src/Data-Functor-Free.html#Free

like image 767
xgrommx Avatar asked Feb 23 '18 01:02

xgrommx


1 Answers

The key here is to understand what it means for a type constructor not to be a functor. It means that it's defined on objects and not on morphisms. But we can describe it as a functor too, if we choose a different source category. For every category C, you can define a discrete category |C|, which has the same objects as C, but no morphisms other than the identity morphisms. A "non-functor" is just a functor from |C| to C. There is a trivial injection functor J from |C| to C that is identity on objects and morphisms (of which there are only identity morphisms). So let's see:

Coyoneda is defined as a left Kan extension of a functor f along the identity functor. It requires f to be a functor.

Free functor looks like Coyoneda, but it's really the left Kan extension of a functor f from |C| to C along J. Strictly speaking J is not identity, but it's close enough, hence the abuse of notation.

The free functor from Sjoerd Visscher's library extends this idea even further. Roughly speaking, a type class in Haskell defines a subcategory of Hask. His free functor is then the left Kan extension of a functor f from that subcategory (or the discrete version of it) to Hask, along the injection of that subcategory into Hask.

like image 122
Bartosz Milewski Avatar answered Sep 23 '22 15:09

Bartosz Milewski