In Backpack, we both typecheck packages with holes (producing only interface files) and compile fully instantiated packages (producing interface files and object files). While doing this, we try to minimize the amount of work the compiler does. In particular:
- Any package with holes is typechecked exactly once, in its most general form (with no instantiations). Partially instantiated packages are never typechecked; instead, we just rename the most general interfaces according to the instantiation "on the fly."
- Any full instantiation of a package is only compiled once.
- To typecheck a package, it's sufficient to have typechecked (not compiled) its dependencies; this lets us avoid waiting to build object code that we aren't actually going to use for typechecking.
- However, if we depend on a package without holes, we should go ahead and compile it, because typechecking doesn't tell us anything beyond what compilation (which also typechecks) would.