Yes, this is safe. The instance you want is:
instance (Monad m, Proxy p) => MonadState s (PS.StateP s p a' a b' b m) where
get = PS.get
put = PS.put
I just want to briefly note that in pipes-4.0.0
(which is on Github) the proxy transformers are no longer necessary and the same extensions are outsourced to monad transformers in the base monad. This means that instead of:
Consumer (StateP s p) a m r
... you would use:
Consumer a (StateT s m) r
This means that you would then just be able to write:
lift $ myLens %= f
However, I still plan on adding MonadState
instances for Proxy
anyway, although perhaps in a separate package (I still haven't decided whether to include them in the main library yet). They would look like this:
instance (MonadState s m) => MonadState s (Proxy a' a b' b m r) where
put s = lift (put s)
get = lift get