Importing and Exporting Instance Declarations

Hello, Can anybody explain or point me to previous discussions about why it isn't allowed to import and export instance declarations? See: section 5.4 of http://haskell.org/onlinereport/modules.html I don't want to propose this for Haskell' (yet) because I think there has to be some very good reasons why this seemingly very obvious feature is missing. regards, Bas van Dijk

Bas van Dijk wrote:
Can anybody explain or point me to previous discussions about why it isn't allowed to import and export instance declarations?
With the exception of instance declarations, the module system deals only with names, not scope. Importing a module just gives new names to things that were (in principle) already in scope. Instance declarations are an unfortunate special case, because (like type signatures and fixity declarations) they don't introduce any identifiers, but (unlike those declarations) they aren't tied to identifiers introduced in the same module. As a result, their very existence destroys the purity of import declarations. I think that this problem could have been prevented by requiring that every instance declaration mention in its head a type or class that was declared in the same module, but I doubt that would go over well -- people already complain enough about the fact that you can't use "deriving" across modules. So explicit import/export of instance declarations would not be a very natural extension. Even if a semantics could be worked out, it would presumably be necessary to preserve the current rules against overlapping instances, meaning that you couldn't do things like hide the Prelude definition of Num Int and define your own locally. -- Ben
participants (2)
-
Bas van Dijk
-
Ben Rudiak-Gould