Closed mvcisback closed 8 years ago
It's a limitation of TupleLens that you can't pass it a traversal since it does an implicit get_monoid
as part of its current implementation. This may be fixable, Ill give it some thought.
In the mean time, you can work around this by extracting the each_
from out of the tuple_
:
right = lens()[1].iso_(lambda a: [a], lambda a: a[0])
lens([[1,3], 4]).tuple_(lens()[0], right).each_().each_().get_all()
This works by constructing a tuple of two lists ([1, 3], [4])
which can then be eached over twice.
This is not fixable, at least not easily.
You would need to add some kind of set_all
method and also a way to distinguish traversal results from ordinary ones. If I understand everything correctly, both of these would require inelegant hacks. I would rather keep the limitation and just improve documentation.
The following example does not appear to work as expected:
Perhaps I'm misunderstanding, but shouldn't the result be [1,3,4] or something? It looks like it's implicitly using the
+
monoid