Hello,

I'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

class (Monad (IM i x)) => Impl i x where
    data IM i x :: * -> *

(where IM means Implementation Monad)

Here, 'x' aims at being a phantom type that ensures a type safe context for some operations.
E.g., operations that need to occur in a window will have the type:
   IM i Window a
And will be run by the function:
   withinWindow :: Window -> IM i Window a -> IM i x a

This makes an operation that doesn't instantiate 'x' context-independent.

My problem, then, is that in the definition of class Impl the type variable 'x' is useless, since every implementation must leave uninstantiated.

I would like to write something like :

class (forall x. Monad (IM i x)) => Impl i where
    data IM i :: * -> * -> *

But GHC forbids me to do so.

Any suggestion would be warmly welcomed.