Category Theory
Zulip Server
Archive

You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.


Stream: learning: questions

Topic: Kleisli charts(/lenses)?


view this post on Zulip Harrison Grodin (Apr 28 2026 at 17:34):

A chart from (A,A+)(A^-, A^+) to (B,B+)(B^-, B^+) is typically represented as a pair of functions f:A+B+f : A^+ \to B^+ and f:A+×ABf_\flat : A^+ \times A^- \to B^-. Equivalently, using exponentials, it's a single function (f,f):A+(B+×(AB))(f, f_\flat) : A^+ \to (B^+ \times (A^- \Rightarrow B^-)).

I've seen @David Jaz Myers (and likely others) generalize charts such that the backwards map is "effectful" using some monad MM, i.e. f:A+×AM(B)f_\flat : A^+ \times A^- \to M(B^-). I've recently encountered a situation, though, that instead looks like a combined map A+M(B+×(AM(B)))A^+ \to M(B^+ \times (A^- \Rightarrow M(B^-))), where the "forward part" is also effectful, and the "reverse part" happens under that same monad. (This map can't literally be broken down using the universal property of the product, since MM need not preserve products or anything.) For a concrete example, the MM I have in mind is the finitely-supported distributions (ie, free convex set) monad.

Has anyone seen this structure before? It feels like a sort of "Kleisli chart"...

view this post on Zulip Martti Karvonen (Apr 28 2026 at 18:20):

I know very little about lenses generally speaking, but can't help but chime in as I'm interested in answers as well. This is because I'm quite familiar with what I suspect to be an instance of this, and in my case the monad is also given by finitely supported distributions (possibly over other semirings too). Namely, in the sheaf-theoretic approach to contextuality the relevant maps of scenarios have both a forward and backward compoinent, making them more or less lenses, and in general we want both of them to be stochastic. See e.g. here where we define the relevant maps by first defining the deterministic maps and then applying the distribution functor to the old homsets (i.e., we freely encrich the starting category in convex sets).

view this post on Zulip Jules Hedges (Apr 28 2026 at 21:30):

You can do this for any symmetric monoidal category: a morphism (A,A+)(B,B+)(A^-, A+) \to (B^-, B^+) is an element of the coend MC(A+,MB+)×C(MA,B)\int^M \mathcal C (A^+, M \otimes B^+) \times \mathcal C (M \otimes A^-, B^-), aka an equivalence class of triples. (If \otimes is a cartesian product this is equivalent to the basic definition of charts). This is a standard way to generalise lenses (the reference for that is Riley, Categories of optics) and it can be usefully generalised more than that too (see Profunctor optics: A categorical update). I never saw anybody write down that it works for charts too, but it's foklore for sure

view this post on Zulip Jules Hedges (Apr 28 2026 at 21:33):

This is almost but not exactly equivalent to the direct definition you wrote (I was confused about this point for years). For lenses I went into excruciating detail about it in this blog post
https://julesh.com/posts/2024-04-12-enriched-closed-lenses.html
which will definitely go exactly the same for charts

view this post on Zulip Jules Hedges (Apr 28 2026 at 21:49):

(I just discovered a formula in that post that didn't survive the migation of my website, I'll fix that tomorrow)

view this post on Zulip Harrison Grodin (Apr 28 2026 at 21:53):

Ohh right, this is exactly what I was looking for, thank you!! I now remember reading this post and finding it very lovely a few years ago, but couldn't quite recall where I'd seen this discussion. :) Many thanks!

view this post on Zulip Bruno Gavranović (Apr 28 2026 at 23:27):

In addition to what was said already, perhaps its useful to point out another "extreme" direction you can take this to. Using lens terminology, you can distinguish between

Of course, all of this works for charts too, which is why I'm mentioning it. While not directly stated at the level of the charts, I unpacked all of this in my thesis (Section 4.3 Weighted Optics), and the trick of flipping the element of the coend that Jules mentioned should apply here too, without a problem.

I found it useful in providing a unifying story of both probability-shaped processes, and also gradient-based ones in a way where you can get a handle on the type of process taking part in each specific component of the lens/chart. It sounds like this might be what you're after here

view this post on Zulip Jules Hedges (Apr 29 2026 at 10:22):

If anyone wants a small puzzle: In the case that C\mathcal C is cartesian, Lens(C)\mathbf{Lens} (\mathcal C) and Chart(C)\mathbf{Chart} (\mathcal C) are both fibred over C\mathcal C and are fibrewise opposites. In the monoidal case neither of them are fibred over C\mathcal C, there should be some 2-categorical sense in which they are probably fibrewise opposite over Copara(C)\mathbf{Copara} (\mathcal C), but this is much less obvious and afaik not written down anywhere

view this post on Zulip Jules Hedges (Apr 29 2026 at 10:24):

The main reason that's important is because you want them to be fibrewise opposites in order to form the monoidal version of Myers' double category of formal commutative squares where horizontal 1-cells are lenses and vertical 1-cells are charts