
On Fri, 2004-08-06 at 15:44, Malcolm Wallace wrote:
Hmm...doesn't
--8<-- module Closed(foo) where class C a where foo = ... instance C ... --8<-- module Main where import Closed ...foo... --8<--
do what you want? You can only use existing instances of C, but not declare them (outside of the Closed module), IIUC.
Ah, but now you cannot use (Closed t) => as a predicate in type signatures, and since you cannot write a partial signature, you must omit the signature altogether...
A similar non-solution is to export the class name but not the class methods, so you cannot defined them in other modules. However this doesn't help if there are default methods or no methods, you can still say: instance ClosedClass Foo Note the lack of 'where' keyword. Granted, for most classes this would stop other modules interfering but it doesn't give the optimisation opportunities or the better overlapping instance detection. Duncan