When I find something interesting and new, I post it here - that's mostly programming, of course, not everything.

Tuesday, October 04, 2016

Union of Functors and a Functor on Union

Union of Functors and a Functor on Union

Intro

On 10/3/2016 Paul Phillips posted an interesting question, https://twitter.com/extempore2/status/783161511724273664?cn=cmVwbHk%3D&refsrc=email - how are \/[F[A], G[A]] and F[A\/B]related. Here are my musings on this. In 2011 I already wrote this: http://vpatryshev.blogspot.com/2011/05/monad-genome-part-1.html - pretty much close to the topic; but it's better to just go into details.

Basics

Let's fix some category C; assume that it has all the necessary limits or colimits.

Union is a special case of a coproduct; it's a functor CCC that is right adjoint to diagonal Δ:C → CC. The diagonal maps an x to (x,x)

This diagonal actually can be defined like this: given 1+11, where 1 is a unit, a terminal category, its exponential, C1+1C1, is the same diagonal Δ.

Union of Two Endofunctors

An endofunctor on category C is a point in CC; and a union of two endofunctors has the following signature: CCCC → Cwhich is the same as (CC)C → CC, or C(1+1C → CC

In Scala its type can be written as (Bool => C => C) => C => C.  Here Bool is a cheap implementation of 1+1.

Since the union is calculated pointwise in this case, this functor, C(1+1C → CC, is a right adjoint to the diagonal  C→ C(1+1C.

Endofunctor following a Union

For the case where we first build a union and then apply a functor, we need three components: two objects and a functor. So we have CCCC → CC - here we map a triple (A,B,F) to F[A\/B].

Rewriting it, we have C1+1+C → CC- this is the signature of our operation. In other words, we have 
((Bool \/ C) => C) => C => C.


Followers

Subscribe To My Podcast

whos.amung.us