Christian.Maeder at dfki.de
Wed Aug 13 07:09:36 EDT 2008
Simon Peyton-Jones wrote:
> | Ashley:
> | What is an orphan instance, and why do we care about them?
> They are documented in the GHC manual
GHC identifies orphan modules, and visits the interface file of every
orphan module below the module being compiled. This is usually wasted
work, but there is no avoiding it. You should therefore do your best to
have as few orphan modules as possible.
> I agree. The warning just warns you that compilation of any module that depends on this module, or on the package of which this module becomes a part, will become a little slower, for reasons explained above.
> Indeed, you could certainly accumulate in every M.hi file a list of all orphan instances anywhere below M. What GHC does instead is to accumulate a list of all the *modules that contain* orphan instances, which amounts to much the same thing. Either way it's tiresome because all these instances must be brought into scope for every compilation, even though most of them are useless.
I still don't understand why ghc will become "slower" with orphaned
modules. Where is "wasted work" or which "instances are useless"?
Doesn't ghc just read all interface files of modules in the import chain
(i.e. all modules "below")? Or is that the "disaster in practice, so GHC
tries to be clever"? In what way is GHC clever? Are only interface files
of directly imported modules (plus orphaned modules mentioned in there)
Is there a difference if I compile each file individually or if I use
If I compile a single module M that does not need instances from an
orphaned module, this orphaned module wouldn't be in the import chain
and therefore I would expect the compilation of M to be faster. (Here I
assume that I've only orphaned instances in orphaned modules.)
Conversely, If all my instances are not orphaned I'll always have
instances in scope that I may not need in some importing module.
Could someone enlighten me?
More information about the Libraries