It can be implemented, by moving to the plain function representation with to and view. But at that point, why insist on an optic representation when you're essentially doing function composition? You can try to add it but it will be difficult to argue this passes the Fairbairn threshold.
well, maybe definitely is too strong a word, I think there's something like this for lenses, but while I've written and used it I haven't proved the result is a valid lens (although I suspect that it is)
I think it's only unsound if b and c (in your example) are not disjoint, which you can't prove from the type definition. I think that's the only reason it's unsound.
but for read-only it seems like it should be fine, because (intuitively) there's no problem with "what does it mean to modify non-disjoint lenses at the same time?"
Is there some combinator like this, but for
Getter
s?I want to be able to write this
I doubt there is in the lens library because the implementation has to give up the VL representation.
this can't be implemented using VL? is there some writeup regarding this somewhere, or is it just a natural consequence of how VL lenses work?
It can be implemented, by moving to the plain function representation with
to
andview
. But at that point, why insist on an optic representation when you're essentially doing function composition? You can try to add it but it will be difficult to argue this passes the Fairbairn threshold.Though there's
lensProduct
in case the two parameters happen to be lenses https://hackage.haskell.org/package/lens-4.19.2/docs/Control-Lens-Unsound.htmlthanks!
@Georgi Lyubenov // googleson78 I don't know about Getters, but there definitely is something like this for lenses
well, maybe definitely is too strong a word, I think there's something like this for lenses, but while I've written and used it I haven't proved the result is a valid lens (although I suspect that it is)
I think the VH lens have an unsound version of this: https://hackage.haskell.org/package/lens-4.19.2/docs/Control-Lens-Unsound.html#v:lensProduct
I think it's only unsound if
b
andc
(in your example) are not disjoint, which you can't prove from the type definition. I think that's the only reason it's unsound.but for read-only it seems like it should be fine, because (intuitively) there's no problem with "what does it mean to modify non-disjoint lenses at the same time?"