I need a function like <<%~
which would act with Traversal
s in similar fashion to ^?
, like this:
(<<?%~) :: Traversal s t a b -> (a -> b) -> s -> (Maybe a, t)
> ix 0 <<?%~ succ $ [1,2]
(Just 1,[2,2])
> ix 1 <<?%~ succ $ [1,2]
(Just 2,[1,3])
> ix 2 <<?%~ succ $ [1,2]
(Nothing,[1,2])
How should I implement it? The obvious way is to apply ^?
and %~
separately, but I'd like a solution in one go.