Open adamgundry opened 3 years ago
That discussion link needs login.
You have a typo, missing p
:
type TraversalC p c s t = (forall a b. c a b => p a b) -> p s t
It would be more correct to speak about constrained optics:
type OpticC p c s t = (forall a b. c a b => p a b) -> p s t
then constrainted traversal would be
type TraversalC c s t = forall p. Traversing p => OpticC p c s t
and similarly constrained lens, prisms, setters, ...
Can/should we generalise optics to support this?
Can: probably yes. Should: I'd rather see someone else try this first.
See discussion starting from https://discord.com/channels/701454007775920128/855385315942203433/855825282833711115
This allows traversing structures containing multiple different types, satisfying a constraint. Pick
c ~ Equals a b
whereclass (a1 ~ a, b1 ~ b) => Equals a b a1 b1
to recover existing traversals.Can/should we generalise
optics
to support this?