Right!
In my case though I don't need lens, only the setter. I have an utility function which sets the "progressBarVisible" in the UI State, but some UI States do not have this progress bar, so I wanted a Setter which does nothing, e.g.
@optics
data class UiState1(title: String, progressBarVisible: Boolean)
@optics
data class UiState2(title: String)
and then
cleverUpdate(
titleLens = UiState1.title,
progressBarVisibleSetter = UiState1.progressBarVisible
)
and I wondered what to do for
UiState2
here.
But after I asked the question I discovered I could do this:
cleverUpdate(
titleLens = UiState2.title,
progressBarVisibleSetter = { state, _ -> state } // this is a PSetter too
)