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 C⨯C → C that is right adjoint to diagonal Δ:C → C⨯C. The diagonal maps an x to (x,x).
This diagonal actually can be defined like this: given 1+1 → 1, where 1 is a unit, a terminal category, its exponential, C1+1 → C1, is the same diagonal Δ.
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+1)×C → CC, is a right adjoint to the diagonal CC → C(1+1)×C.
((Bool \/ C) => C) => C => C.Union of Two Endofunctors
An endofunctor on category C is a point in CC; and a union of two endofunctors has the following signature: CC⨯CC → CC which is the same as (C⨯C)C → CC, or C(1+1)×C → CCIn 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+1)×C → CC, is a right adjoint to the diagonal CC → C(1+1)×C.
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 C⨯C⨯CC → 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
No comments:
Post a Comment