Hot take: optics are better abstraction than lenses, in *all* use cases. Why? They make explicit all the things you're implicitly thinking about anyway when using lenses. I think they are really important in shaping how we think about bidirectional maps. A short thread. 👇 1/9

Optics make explicit 1) the internal state (residual) and 2) the fact that you need to have the base category either be Cartesian, or at the very least have the "get" maps be comonoid homomorphisms. Let's look at the state/residual.
2/9
In lenses, this state is always the same as the input and is implicit. This can be seen by repackaging the get map from get: X → Y to Δₓ;(get×X):X e→ Y×X. Now our new get map (in addition to computing the output) passes through the input. This is good for a few reasons. 3/9
First, this pleasantly symmetric with the put:X×Y'→X'. But also, this new map is now exactly the "left" map of an optic too. (It turns out put was all along the "right" map). This tells us that the passed-through input is actually the state we're remembering. 4/9
But most importantly, this formulation is now explicit in the use of the copy map Δₓ:X → X×X, which you might have not realized is needed if you were just thinking about the standard get-put formulation. Furthermore, when you were composing lenses, ... 5/9
the formulation of the composite of the put maps was always much more complex than get maps. But now it's obvious why you needed to do that: you were juggling the internal state/residual around, because it had to agree with the input. 6/9
But you don't need to do that with optics (and that's the whole idea): you can *choose* the internal state you want.
With lenses you're using a specific state anyway, but you aren't given the conceptual tools to talk about it.
But let's stop here and see what we've done. 7/9
Observe that we didn't really "add" any complexity so far. All we've done is distilled what was already there and gave it a name. That's the whole idea behind of a lot of category theory. 8/9
Now, we still have to pack up this new construction and be precise in its definition. That's exactly what the coend in the optic definition does. It might even look scary, but it turns out the coend is saying some incredibly natural things. But that's for some other time. 9/9
References:
Optics: https://t.co/nWBhDR0Hut
Generalized Lens Categories: https://t.co/C0gB06B9DE
Also, this perspective was first shared with me here: https://t.co/ThvRcV2j3t
Also, I should add a caveat that I'm not necessarily talking about *mixed* optics. These seem like a complex beast that I don't yet understand fully.

More from Health

@73inlancs @janethooton_ @ErinInTheMorn @fifi_EY 1/ The 🏴󠁧󠁢󠁥󠁮󠁧󠁿 government decided pediatric gender care in England would be a monopoly contract (a Labour minister, in 2008), despite all other NHS patients officially being entitled to a choice of providers, & second opinions on diagnoses & treatment, & gave it to GIDS, which has…

@janethooton_ @ErinInTheMorn @fifi_EY 2/…always advocated that trans minors & their families must have no alternative source of care, & subsequent Tory ministers have personally put their signature on renewals of it, and even personally rejected proposals for improvement that have been put forward by NHS England…

@janethooton_ @ErinInTheMorn @fifi_EY 3/…as a result of wider & public consultation. They & their civil servants listen only to GIDS on trans minors - it was GIDS advised against <18s being allowed #GenderRecognition in 2004, & since, on the basis that no one under 18 can be certain of their gender identity, just…

@janethooton_ @ErinInTheMorn @fifi_EY 4/…as many other staff at their trust wrote⬇️ to the press in 2002 (when the first instigator of this case, psychoanalyst Susan Evans was on staff too) that no trans people should be allowed that recognition but needed

@janethooton_ @ErinInTheMorn @fifi_EY 5/…to "cure" us instead. Yet GIDS proved incapable of defending its super-conservative protocol in court - no doubt because GIDS has always expected challenges to be from patients seeking care more like that elsewhere, arrogantly ignoring that services in countries where the…

You May Also Like