on a scale of 0 to 10, how wrong is this solution?...
# arrow
c
on a scale of 0 to 10, how wrong is this solution?
Copy code
fun <T, A> Lens<T, List<A>>.index(state: T, predicate: (A) -> Boolean): Optional<T, A> =
  this.getOrNull(state)?.let { this.compose(Index.list<A>().index(it.indexOfFirst(predicate))) } ?: Optional.void()
Copy code
State.posts.index(state) { it.id == postId }.likes transform { it + 1 }
y
I think that is covered by: https://github.com/arrow-kt/arrow/pull/3454. You could copy the implementation into your own code theoretically