のような署名を持つ関数はありますか
lensMapState[S, T, A](lens : Lens[S, T]): State[T, A] => State[S, A]
セマンティクスを使用して、選択した部分の変更を実行し、結果を取得します
1つの実装は
def lensMapState[S, T, A](lens: Lens[S, T]): State[T, A] => State[S, A] =
stateT => State { s =>
val (result, x) = stateT.run(lens.get(s))
(lens.set(result)(s), x)
}
しかし、 monocleまたはscalaz.Lensを使用するより簡単な方法があれば?