Anonymous
11/9/2025, 2:03:29 AM
No.107148539
>>107148460
what we're talking about is this
if you have (a, b) you can use a lens to the second component to turn the b into c, getting (a, c), you could then swap the a out for d to get (d, c)
but for some types, the types of the two fields are linked, e.g.
data Closure a b = Closure { fun :: a -> b, arg :: a }
with a lens onto fun, you could modify the function to change the return type to c, giving you Closure a c from Closure a b. But you can't modify a by modifying 1 field. You have to modify both fields simultaneously because they both reference a.
Another case is existentials
what we're talking about is this
if you have (a, b) you can use a lens to the second component to turn the b into c, getting (a, c), you could then swap the a out for d to get (d, c)
but for some types, the types of the two fields are linked, e.g.
data Closure a b = Closure { fun :: a -> b, arg :: a }
with a lens onto fun, you could modify the function to change the return type to c, giving you Closure a c from Closure a b. But you can't modify a by modifying 1 field. You have to modify both fields simultaneously because they both reference a.
Another case is existentials