instance visibility (was: Re: The base library and GHC 6.10)

Jonathan Cast jonathanccast at
Wed Sep 24 12:28:04 EDT 2008

On Wed, 2008-09-24 at 17:30 +0100, Claus Reinke wrote:
> > (sorry for the delay in replying to this...)
> No problem, though you seem to be restating your opinion 
> intead of addressing my concrete points? For those who, like
> me, have lost the thread in the meantime, here is a link to the 
> message you reply to:
> >>> .., the only sensible way to think about instances is as global properties.
> > has nothing to do with bugs or misfeatures in GHC, it's a 
> > fact of Haskell 98.
> I thought my example demonstrated quite clearly that instances 
> are *not* global in Haskell.
> >> A type class specifies a relation between types. Both the types
> >> and the class are named, and if instances are placed in separate
> >> modules, the modules are named as well. The combination of
> >> module, class and type names gives quite a bit of control over instance 
> >> import/export, even if it is terribly cumbersome and
> >> limited (and easily defeated by just one library importing all
> >> instances "for convenience"). Neither the relation (class), nor
> >> its domain (types), nor its extent (instances) are "global".
> > 
> > The point is that instances are unconditionally re-exported, 
> Yes, and I'm not disputing that point. What I am disputing are
> its consequences/interpretation. As I said, instances accumulate 
> upwards along the import hierarchy. But they do not propagate 
> downwards, so they do not have global scope, and one can exert 
> some control over all of type relation (class), domain (types), and 
> extent (instances).
> What one cannot do (in Haskell 98) is to have two instances of
> the same class, for the same types, in the same import hierarchy.

Of course, when you consider that Main, by definition, imports every
module in the program directly or indirectly, this is pretty close to
saying `instances are global'.  Isn't it?


More information about the Libraries mailing list