title: Zoom instance for ReaderT IORef
body: <p>I'm new to lens and having trouble implementing the Zoom instance for this type:</p>
  
  <pre><code>newtype MyStateT s m a = MyStateT
      { unMyStateT :: ReaderT (IORef s) m a
      } deriving (Functor, Applicative, Monad, MonadIO)
  
  instance (MonadIO m) =&gt; MonadState s (MyStateT s m) where
      get = MyStateT $ ReaderT $ liftIO . readIORef
      put x = MyStateT $ ReaderT $ \ref -&gt; liftIO $ writeIORef ref x
  </code></pre>
  
  <p>I've been trying to make a new IORef with the lens substate, run the ReaderT on that substate, and then grab the changed substate and replace it in the main IORef:</p>
  
  <pre><code>type instance Zoomed (MyStateT s m) = Focusing m
  instance (Monad m) =&gt; Zoom (MyStateT s m) (MyStateT t m) s t where
      zoom l (MyStateT r) =
          MyStateT $ ReaderT $ \ref -&gt; do
              s &lt;- liftIO $ readIORef ref
              ref' &lt;- liftIO $ newIORef $ s ^. l
              let v = runReader r ref'
              subS' &lt;- liftIO $ readIORef ref'
              let s' = s &amp; l .~ subS'
              liftIO $ writeIORef ref s'
              return v
  </code></pre>
  
  <p><code>l</code> seems to be different from a normal lens so <code>^.</code> and <code>.~</code> doesn't compile with it and I get errors like this:</p>
  
  <pre><code>    • Couldn't match type ‘Focusing m c t’ with ‘Const s t’
    Expected type: Getting s t s
      Actual type: LensLike' (Zoomed (MyStateT s m) c) t s
     • Couldn't match type ‘Focusing m c t’ with ‘Identity t’
    Expected type: ASetter t t s s
      Actual type: LensLike' (Zoomed (MyStateT s m) c) t s
  </code></pre>
  
  <p>Can anyone help me get this Zoom instance to work properly? Thanks!</p>