python-lenses icon indicating copy to clipboard operation
python-lenses copied to clipboard

lens.Tuple but for Getters

Open moteutsch opened this issue 3 years ago • 2 comments

Hey, it would be useful to have a version of lens.Tuple that accepts two getters.

(Implementation in pseudo-code:) Could make a class GetterTuple(getters) which has type Getter and whose getter returns (getters[0].get(), ...). And then add a GetterTuple to method which creates such a getter and composes it with the current lens.

moteutsch avatar Feb 21 '22 19:02 moteutsch

Even better: Use the same method lens.Tuple but detect which case we are in: whether the meet of the two kinds is a lens or only a Getter.

moteutsch avatar Feb 21 '22 19:02 moteutsch

I've just pushed a commit that removes the restriction on lens.Tuple that you have to pass lenses. You can now pass it getters and setters and it should do the right thing.

ingolemo avatar Feb 21 '22 20:02 ingolemo