simon.vergauwen
02/14/2020, 6:17 PMfilterIndex does not exist yet in the DSL. If you’re interessed in contributing it that’d be great! Here is an example on how it’s done for Index and it neighbouring files you can find the same for At & Each.
The one that is missing in your example would be.
fun <T, S, I, A> Lens<T, S>.filterIndex(ID: FilterIndex<S, I, A>, p: (I) -> Boolean): Traversal<T, A> = this.compose(ID.filter(p))
val lens = MyClass.listProperty
.filterIndex(ListExtensions.filterIndex()) { index -> index % 2 }
.itemProperty
var myObject = MyClass()
myObject = lens.modify(myObject) { "modified string" }
The DSL is interchangeable with traditional composing so
(MyClass.listProperty compose ListExtensions.filterIndex().filter { index -> index % 2 }).itemProperty also works