title: Impose constraint on MonadIO return type
body: <p>I'm trying to make an instance of <code>MonadIO</code> for a type that represents computations in the cloud. So <code>liftIO</code> would represent an <code>IO</code> action that is executed locally.</p>
  
  <p><a href="https://hackage.haskell.org/package/transient-universe-0.4.6.1/docs/Transient-Move.html#t:Cloud" rel="nofollow noreferrer">transient-universe</a>, the library that provides this, provides a function <code>localIO</code> that does exactly this. But it is not composable in some other library that could embed any other <code>MonadIO</code>.</p>
  
  <p>The problem is, that <code>localIO</code> requires the return type of the <code>IO</code> action to be an instance of <code>Read</code>, <code>Show</code> and <code>Typeable</code>. Whereas <code>MonadIO</code> doesn't contemplate this case:</p>
  
  <pre><code>class MonadIO m where
      liftIO :: IO a -&gt; m a
  </code></pre>
  
  <p>In my case, I'd need to write another type class, that does it:</p>
  
  <pre><code>class RestrictableMonadIO (m a) where
      liftRestrictedIO :: IO a -&gt; m a
  </code></pre>
  
  <p>So it would allow me to do this:</p>
  
  <pre><code>instance (Read a, Show a, Typeable a) =&gt; MonadIO (Cloud a) where
      liftRestrictedIO = localIO
  </code></pre>
  
  <p>Is there a way of doing this without having to declare my own typeclass?</p>