ghc-8.2.1: The GHC API

Safe HaskellNone



This module implements interface renaming, which is used to rewrite interface files on the fly when we are doing indefinite typechecking and need instantiations of modules which do not necessarily exist yet.



rnModIface :: HscEnv -> [(ModuleName, Module)] -> Maybe NameShape -> ModIface -> IO (Either ErrorMessages ModIface) Source #

What we have is a generalized ModIface, which corresponds to a module that looks like p[A=A]:B. We need a *specific* ModIface, e.g. p[A=q():A]:B (or maybe even p[A=B]:B) which we load up (either to merge it, or to just use during typechecking).

Suppose we have:

p[A=A]:M ==> p[A=q():A]:M

Substitute all occurrences of A with q():A (renameHoleModule). Then, for any Name of form {A.T}, replace the Name with the Name according to the exports of the implementing module. This works even for p[A=B]:M, since we just read in the exports of B.hi, which is assumed to be ready now.

This function takes an optional NameShape, which can be used to further refine the identities in this interface: suppose we read a declaration for {H.T} but we actually know that this should be Foo.T; then we'll also rename this (this is used when loading an interface to merge it into a requirement.)

rnModExports :: HscEnv -> [(ModuleName, Module)] -> ModIface -> IO (Either ErrorMessages [AvailInfo]) Source #

Rename just the exports of a ModIface. Useful when we're doing shaping prior to signature merging.