
Daniel Fischer
No, that is the catch:
undefined :: Source NotAnInstanceOfVariable Int
is possible.
OK, I've got that. Now let's say that data Source v a = Variable v => Source {bindings :: v [Binding a], var :: v a} or data Variable v => Source v a = Source {bindings :: v [Binding a], var :: v a} instance Variable (Source v) where newVar a = do bindings <- newVar [] v <- newVar a return $ Source bindings v was allowed - then newVar (undefined :: Source NotAnInstanceOfVariable Int) would then attempt newVar (?? :: NotAnInstanceOfVariable), which doesn't type check, because newVar only works on Variables. Is this correct? If that's the only problem, it doesn't seem like much of a loss, as even with the type context, undefined :: Source SomeInstanceOfVariable Int isn't going to be of much use either.