I currently have code that looks like this:
do
x <- use foo
foo <~ runFoo x
where foo
is a Lens
to a Foo
field and runFoo :: MonadState m => Foo -> m Foo
I think there should be a way to do this operation in one line, but I cannot find it. I think it ought to have a comment like:
(????) :: MonadState s m => Lens' s a -> (a -> m a) -> m a
Questions:
- Does such a combinator exist? if so what is it?
- When I run into another question like this, what is the best way to search for it (i.e. Usually I would just type this into Hoogle but I've not had good luck doing that with the lens library)
- Is this actually a primitive combinator found in Control.Monad? (I will be slightly embarrassed if this is yet another job for the kleisli arrow)