Hello,<br><br>I&#39;m working on a library which aims to be a generic interface for 2D rendering. To do that, one of my goals is to enable each implementation of this interface to run in its own monad (most of the time an overlay to IO), thus giving me the following class<br>

<br><span style="font-family: courier new,monospace;">class (Monad (IM i x)) =&gt; Impl i x where</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    data IM i x :: * -&gt; *</span><br style="font-family: courier new,monospace;">

<br>(where IM means Implementation Monad)<br><br>Here, &#39;x&#39; aims at being a phantom type that ensures a type safe context for some operations.<br>E.g., operations that need to occur in a window will have the type:<br>

<span style="font-family: courier new,monospace;">   IM i Window a</span><br>And will be run by the function:<br><span style="font-family: courier new,monospace;">   withinWindow :: Window -&gt; IM i Window a -&gt; IM i x a</span><br>

<br>This makes an operation that doesn&#39;t instantiate &#39;x&#39; context-independent.<br><br>My problem, then, is that in the definition of class Impl the type variable &#39;x&#39; is useless, since every implementation must leave uninstantiated.<br>

<br>I would like to write something like :<br><br>class (forall x. Monad (IM i x)) =&gt; Impl i where<br>    data IM i :: * -&gt; * -&gt; *<br><br>But GHC forbids me to do so.<br><br>Any suggestion would be warmly welcomed.<br>