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

Claus Reinke claus.reinke at
Thu Sep 25 13:13:42 EDT 2008

> Another reason to prefer the global interpretation of instances is
> that it allows for more efficient, non-dictionary-passing
> implementations of type classes. Both JHC's type-case and Mark Jones's
> partial evaluation techniques require instances that are the same
> everywhere.

Why would partial evaluation require global instances? Mark's
prototype implementation ignored separate compilation issues
by requiring all modules to be available at specialisation time.

But that does not imply that specialisation is limited to a one
instance-per-program view, it just has to be clear which instance
to specialise at any point. That needs to be clear for any
implementation of type classes, with or without dictionaries,
but the consequences differ slighly: in a dictionary-based
implementation, undecided instances mean dictionaries parameters,
to be supplied at usage points; in a dictionary-free implementation,
undecided instances mean general code, to be specialised at
usage points. Right?


More information about the Libraries mailing list