Commit 2e42ca27 authored by Edward Z. Yang's avatar Edward Z. Yang

Rename IndefModule to OpenModule.

Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 62ddf8e0
......@@ -15,17 +15,17 @@ module Distribution.Backpack (
openUnitIdComponentId,
openUnitIdFreeHoles,
-- * IndefModule
IndefModule(..),
indefModuleFreeHoles,
-- * IndefModuleSubst
IndefModuleSubst,
dispIndefModuleSubst,
dispIndefModuleSubstEntry,
parseIndefModuleSubst,
parseIndefModuleSubstEntry,
indefModuleSubstFreeHoles,
-- * OpenModule
OpenModule(..),
openModuleFreeHoles,
-- * OpenModuleSubst
OpenModuleSubst,
dispOpenModuleSubst,
dispOpenModuleSubstEntry,
parseOpenModuleSubst,
parseOpenModuleSubstEntry,
openModuleSubstFreeHoles,
-- * Conversions to 'UnitId'
abstractUnitId,
......@@ -77,10 +77,10 @@ import qualified Data.Set as Set
data OpenUnitId
-- | Identifies a component which may have some unfilled holes;
-- specifying its 'ComponentId' and its 'IndefModuleSubst'.
-- TODO: Invariant that 'IndefModuleSubst' is non-empty?
-- specifying its 'ComponentId' and its 'OpenModuleSubst'.
-- TODO: Invariant that 'OpenModuleSubst' is non-empty?
-- See also the Text instance.
= IndefFullUnitId ComponentId IndefModuleSubst
= IndefFullUnitId ComponentId OpenModuleSubst
-- | Identifies a fully instantiated component, which has
-- been compiled and abbreviated as a hash. The embedded 'UnitId'
-- MUST NOT be for an indefinite component; an 'OpenUnitId'
......@@ -100,14 +100,14 @@ instance Text OpenUnitId where
-- TODO: arguably a smart constructor to enforce invariant would be
-- better
| Map.null insts = disp cid
| otherwise = disp cid <<>> Disp.brackets (dispIndefModuleSubst insts)
| otherwise = disp cid <<>> Disp.brackets (dispOpenModuleSubst insts)
disp (DefiniteUnitId uid) = disp uid
parse = parseOpenUnitId <++ fmap DefiniteUnitId parse
where
parseOpenUnitId = do
cid <- parse
insts <- Parse.between (Parse.char '[') (Parse.char ']')
parseIndefModuleSubst
parseOpenModuleSubst
return (IndefFullUnitId cid insts)
-- | Get the 'ComponentId' of an 'OpenUnitId'.
......@@ -117,89 +117,89 @@ openUnitIdComponentId (DefiniteUnitId uid) = unitIdComponentId uid
-- | Get the set of holes ('ModuleVar') embedded in a 'UnitId'.
openUnitIdFreeHoles :: OpenUnitId -> Set ModuleName
openUnitIdFreeHoles (IndefFullUnitId _ insts) = indefModuleSubstFreeHoles insts
openUnitIdFreeHoles (IndefFullUnitId _ insts) = openModuleSubstFreeHoles insts
openUnitIdFreeHoles _ = Set.empty
-----------------------------------------------------------------------
-- IndefModule
-- OpenModule
-- | Unlike a 'Module', an 'IndefModule' is either an ordinary
-- module from some unit, OR an 'IndefModuleVar', representing a
-- | Unlike a 'Module', an 'OpenModule' is either an ordinary
-- module from some unit, OR an 'OpenModuleVar', representing a
-- hole that needs to be filled in. Substitutions are over
-- module variables.
data IndefModule
= IndefModule OpenUnitId ModuleName
| IndefModuleVar ModuleName
data OpenModule
= OpenModule OpenUnitId ModuleName
| OpenModuleVar ModuleName
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
instance Binary IndefModule
instance Binary OpenModule
instance NFData IndefModule where
rnf (IndefModule uid mod_name) = rnf uid `seq` rnf mod_name
rnf (IndefModuleVar mod_name) = rnf mod_name
instance NFData OpenModule where
rnf (OpenModule uid mod_name) = rnf uid `seq` rnf mod_name
rnf (OpenModuleVar mod_name) = rnf mod_name
instance Text IndefModule where
disp (IndefModule uid mod_name) =
instance Text OpenModule where
disp (OpenModule uid mod_name) =
hcat [disp uid, Disp.text ":", disp mod_name]
disp (IndefModuleVar mod_name) =
disp (OpenModuleVar mod_name) =
hcat [Disp.char '<', disp mod_name, Disp.char '>']
parse = parseModuleVar <++ parseIndefModule
parse = parseModuleVar <++ parseOpenModule
where
parseIndefModule = do
parseOpenModule = do
uid <- parse
_ <- Parse.char ':'
mod_name <- parse
return (IndefModule uid mod_name)
return (OpenModule uid mod_name)
parseModuleVar = do
_ <- Parse.char '<'
mod_name <- parse
_ <- Parse.char '>'
return (IndefModuleVar mod_name)
return (OpenModuleVar mod_name)
-- | Get the set of holes ('ModuleVar') embedded in a 'Module'.
indefModuleFreeHoles :: IndefModule -> Set ModuleName
indefModuleFreeHoles (IndefModuleVar mod_name) = Set.singleton mod_name
indefModuleFreeHoles (IndefModule uid _n) = openUnitIdFreeHoles uid
openModuleFreeHoles :: OpenModule -> Set ModuleName
openModuleFreeHoles (OpenModuleVar mod_name) = Set.singleton mod_name
openModuleFreeHoles (OpenModule uid _n) = openUnitIdFreeHoles uid
-----------------------------------------------------------------------
-- IndefModuleSubst
-- OpenModuleSubst
-- | An explicit substitution on modules.
--
-- NB: These substitutions are NOT idempotent, for example, a
-- valid substitution is (A -> B, B -> A).
type IndefModuleSubst = Map ModuleName IndefModule
type OpenModuleSubst = Map ModuleName OpenModule
-- | Pretty-print the entries of a module substitution, suitable
-- for embedding into a 'OpenUnitId' or passing to GHC via @--instantiate-with@.
dispIndefModuleSubst :: IndefModuleSubst -> Disp.Doc
dispIndefModuleSubst subst
dispOpenModuleSubst :: OpenModuleSubst -> Disp.Doc
dispOpenModuleSubst subst
= Disp.hcat
. Disp.punctuate Disp.comma
$ map dispIndefModuleSubstEntry (Map.toAscList subst)
$ map dispOpenModuleSubstEntry (Map.toAscList subst)
-- | Pretty-print a single entry of a module substitution.
dispIndefModuleSubstEntry :: (ModuleName, IndefModule) -> Disp.Doc
dispIndefModuleSubstEntry (k, v) = disp k <<>> Disp.char '=' <<>> disp v
dispOpenModuleSubstEntry :: (ModuleName, OpenModule) -> Disp.Doc
dispOpenModuleSubstEntry (k, v) = disp k <<>> Disp.char '=' <<>> disp v
-- | Inverse to 'dispModSubst'.
parseIndefModuleSubst :: ReadP r IndefModuleSubst
parseIndefModuleSubst = fmap Map.fromList
parseOpenModuleSubst :: ReadP r OpenModuleSubst
parseOpenModuleSubst = fmap Map.fromList
. flip Parse.sepBy (Parse.char ',')
$ parseIndefModuleSubstEntry
$ parseOpenModuleSubstEntry
-- | Inverse to 'dispModSubstEntry'.
parseIndefModuleSubstEntry :: ReadP r (ModuleName, IndefModule)
parseIndefModuleSubstEntry =
parseOpenModuleSubstEntry :: ReadP r (ModuleName, OpenModule)
parseOpenModuleSubstEntry =
do k <- parse
_ <- Parse.char '='
v <- parse
return (k, v)
-- | Get the set of holes ('ModuleVar') embedded in a 'IndefModuleSubst'.
-- | Get the set of holes ('ModuleVar') embedded in a 'OpenModuleSubst'.
-- This is NOT the domain of the substitution.
indefModuleSubstFreeHoles :: IndefModuleSubst -> Set ModuleName
indefModuleSubstFreeHoles insts = Set.unions (map indefModuleFreeHoles (Map.elems insts))
openModuleSubstFreeHoles :: OpenModuleSubst -> Set ModuleName
openModuleSubstFreeHoles insts = Set.unions (map openModuleFreeHoles (Map.elems insts))
-----------------------------------------------------------------------
-- Conversions to UnitId
......@@ -212,8 +212,8 @@ abstractUnitId (DefiniteUnitId uid) = uid
abstractUnitId (IndefFullUnitId cid _) = newSimpleUnitId cid
-- | Take a module substitution and hash it into a string suitable for
-- 'UnitId'. Note that since this takes 'Module', not 'IndefModule',
-- you are responsible for recursively converting 'IndefModule'
-- 'UnitId'. Note that since this takes 'Module', not 'OpenModule',
-- you are responsible for recursively converting 'OpenModule'
-- into 'Module'. See also "Distribution.Backpack.ReadyComponent".
hashModuleSubst :: Map ModuleName Module -> Maybe String
hashModuleSubst subst
......
......@@ -248,8 +248,8 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
= Installed.ExposedModule modname' Nothing
| otherwise
= Installed.ExposedModule modname'
(Just (IndefModule (DefiniteUnitId uid) modname))
convIndefModuleExport (modname', modu@(IndefModule uid modname))
(Just (OpenModule (DefiniteUnitId uid) modname))
convOpenModuleExport (modname', modu@(OpenModule uid modname))
-- TODO: This isn't a good enough test if we have mutual
-- recursion (but maybe we'll get saved by the module name
-- check regardless.)
......@@ -258,19 +258,19 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
= Installed.ExposedModule modname' Nothing
| otherwise
= Installed.ExposedModule modname' (Just modu)
convIndefModuleExport (_, IndefModuleVar _)
= error "convIndefModuleExport: top-level modvar"
convOpenModuleExport (_, OpenModuleVar _)
= error "convOpenModuleExport: top-level modvar"
exports =
-- Loses invariants
case rc_i rc of
Left indefc -> map convIndefModuleExport
Left indefc -> map convOpenModuleExport
$ Map.toList (indefc_provides indefc)
Right instc -> map convModuleExport
$ Map.toList (instc_provides instc)
insts =
case rc_i rc of
Left indefc -> [ (m, IndefModuleVar m) | m <- indefc_requires indefc ]
Right instc -> [ (m, IndefModule (DefiniteUnitId uid') m')
Left indefc -> [ (m, OpenModuleVar m) | m <- indefc_requires indefc ]
Right instc -> [ (m, OpenModule (DefiniteUnitId uid') m')
| (m, Module uid' m') <- instc_insts instc ]
in LibComponentLocalBuildInfo {
componentPackageDeps = cpds,
......
......@@ -11,7 +11,7 @@ import Distribution.Package
import Distribution.Compat.Prelude
-- Unlike OpenUnitId, which could direct to a UnitId.
data FullUnitId = FullUnitId ComponentId IndefModuleSubst
data FullUnitId = FullUnitId ComponentId OpenModuleSubst
deriving (Show, Generic)
type FullDb = UnitId -> FullUnitId
......
......@@ -48,7 +48,7 @@ data LinkedComponent
= LinkedComponent {
lc_uid :: OpenUnitId,
lc_pkgid :: PackageId,
lc_insts :: [(ModuleName, IndefModule)],
lc_insts :: [(ModuleName, OpenModule)],
lc_component :: Component,
lc_shape :: ModuleShape,
-- | Local buildTools dependencies
......@@ -151,7 +151,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
--
let convertReq :: ModuleName -> UnifyM s (ModuleScopeU s)
convertReq req = do
req_u <- convertModule (IndefModuleVar req)
req_u <- convertModule (OpenModuleVar req)
return (Map.empty, Map.singleton req req_u)
-- NB: We DON'T convert locally defined modules, as in the
-- absence of mutual recursion across packages they
......@@ -174,7 +174,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
-- the actual modules we export ourselves. Add them!
let reqs = modScopeRequires linked_shape0
-- check that there aren't pre-filled requirements...
insts = [ (req, IndefModuleVar req)
insts = [ (req, OpenModuleVar req)
| req <- Set.toList reqs ]
this_uid = IndefFullUnitId this_cid . Map.fromList $ insts
......@@ -182,7 +182,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
local_exports = Map.fromListWith (++) $
[ (mod_name, [ModuleSource (packageName this_pid)
defaultIncludeRenaming
(IndefModule this_uid mod_name)])
(OpenModule this_uid mod_name)])
| mod_name <- src_provs ]
-- NB: do NOT include hidden modules here: GHC 7.10's ghc-pkg
-- won't allow it (since someone could directly synthesize
......@@ -231,7 +231,7 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
provs <- foldM build_reexports Map.empty $
-- TODO: doublecheck we have checked for
-- src_provs duplicates already!
[ (mod_name, IndefModule this_uid mod_name) | mod_name <- src_provs ] ++
[ (mod_name, OpenModule this_uid mod_name) | mod_name <- src_provs ] ++
reexports_list
let final_linked_shape = ModuleShape provs (modScopeRequires linked_shape)
......
......@@ -27,11 +27,11 @@ class ModSubst a where
-- putting it on the right hand side, but for partial
-- application it's more convenient to have it on the left
-- hand side.
modSubst :: IndefModuleSubst -> a -> a
modSubst :: OpenModuleSubst -> a -> a
instance ModSubst IndefModule where
modSubst subst (IndefModule cid mod_name) = IndefModule (modSubst subst cid) mod_name
modSubst subst mod@(IndefModuleVar mod_name)
instance ModSubst OpenModule where
modSubst subst (OpenModule cid mod_name) = OpenModule (modSubst subst cid) mod_name
modSubst subst mod@(OpenModuleVar mod_name)
| Just mod' <- Map.lookup mod_name subst = mod'
| otherwise = mod
......@@ -42,7 +42,7 @@ instance ModSubst OpenUnitId where
instance ModSubst (Set ModuleName) where
modSubst subst reqs
= Set.union (Set.difference reqs (Map.keysSet subst))
(indefModuleSubstFreeHoles subst)
(openModuleSubstFreeHoles subst)
-- Substitutions are functorial. NB: this means that
-- there is an @instance 'ModSubst' 'ModuleSubst'@!
......
......@@ -71,7 +71,7 @@ data ModuleSource =
-- with that as well
msrc_pkgname :: PackageName,
msrc_renaming :: IncludeRenaming,
msrc_module :: IndefModule
msrc_module :: OpenModule
}
instance ModSubst ModuleScope where
......
......@@ -27,7 +27,7 @@ import qualified Data.Set as Set
-- a library. We can extract a 'ModuleShape' from an
-- 'InstalledPackageInfo'.
data ModuleShape = ModuleShape {
modShapeProvides :: IndefModuleSubst,
modShapeProvides :: OpenModuleSubst,
modShapeRequires :: Set ModuleName
}
deriving (Eq, Show, Generic)
......@@ -78,6 +78,6 @@ shapeInstalledPackage ipi = ModuleShape (Map.fromList provs) reqs
provs = map shapeExposedModule (IPI.exposedModules ipi)
reqs = requiredSignatures ipi
shapeExposedModule (IPI.ExposedModule mod_name Nothing)
= (mod_name, IndefModule uid mod_name)
= (mod_name, OpenModule uid mod_name)
shapeExposedModule (IPI.ExposedModule mod_name (Just mod))
= (mod_name, mod)
......@@ -55,7 +55,7 @@ data InstantiatedComponent
data IndefiniteComponent
= IndefiniteComponent {
indefc_requires :: [ModuleName],
indefc_provides :: Map ModuleName IndefModule,
indefc_provides :: Map ModuleName OpenModule,
indefc_includes :: [(OpenUnitId, ModuleRenaming)]
}
......@@ -230,15 +230,15 @@ toReadyComponents pid_map subst0 comps
-- NB: NOT composition
substSubst :: Map ModuleName Module
-> Map ModuleName IndefModule
-> Map ModuleName OpenModule
-> InstM (Map ModuleName Module)
substSubst subst insts = T.mapM (substModule subst) insts
substModule :: Map ModuleName Module -> IndefModule -> InstM Module
substModule subst (IndefModuleVar mod_name)
substModule :: Map ModuleName Module -> OpenModule -> InstM Module
substModule subst (OpenModuleVar mod_name)
| Just m <- Map.lookup mod_name subst = return m
| otherwise = error "substModule: non-closing substitution"
substModule subst (IndefModule uid mod_name) = do
substModule subst (OpenModule uid mod_name) = do
uid' <- substUnitId subst uid
return (Module uid' mod_name)
......
......@@ -251,8 +251,8 @@ convertUnitId' stk (IndefFullUnitId cid insts) = do
-- convertUnitId' stk (UnitIdVar i) = return (lookupMuEnv stk i)
convertModule' :: MuEnv s
-> IndefModule -> UnifyM s (ModuleU s)
convertModule' _stk (IndefModuleVar mod_name) = do
-> OpenModule -> UnifyM s (ModuleU s)
convertModule' _stk (OpenModuleVar mod_name) = do
hmap <- fmap unify_reqs getUnifEnv
hm <- readUnifRef hmap
case Map.lookup mod_name hm of
......@@ -260,14 +260,14 @@ convertModule' _stk (IndefModuleVar mod_name) = do
writeUnifRef hmap (Map.insert mod_name mod hm)
return mod
Just mod -> return mod
convertModule' stk (IndefModule uid mod_name) = do
convertModule' stk (OpenModule uid mod_name) = do
uid_u <- convertUnitId' stk uid
liftST $ UnionFind.fresh (ModuleU uid_u mod_name)
convertUnitId :: OpenUnitId -> UnifyM s (UnitIdU s)
convertUnitId = convertUnitId' emptyMuEnv
convertModule :: IndefModule -> UnifyM s (ModuleU s)
convertModule :: OpenModule -> UnifyM s (ModuleU s)
convertModule = convertModule' emptyMuEnv
......@@ -279,11 +279,11 @@ convertModule = convertModule' emptyMuEnv
type ModuleSubstU s = Map ModuleName (ModuleU s)
-- | Conversion of 'ModuleSubst' to 'ModuleSubstU'
convertModuleSubst :: Map ModuleName IndefModule -> UnifyM s (Map ModuleName (ModuleU s))
convertModuleSubst :: Map ModuleName OpenModule -> UnifyM s (Map ModuleName (ModuleU s))
convertModuleSubst = T.mapM convertModule
-- | Conversion of 'ModuleSubstU' to 'ModuleSubst'
convertModuleSubstU :: ModuleSubstU s -> UnifyM s IndefModuleSubst
convertModuleSubstU :: ModuleSubstU s -> UnifyM s OpenModuleSubst
convertModuleSubstU = T.mapM convertModuleU
-----------------------------------------------------------------------
......@@ -322,21 +322,21 @@ convertUnitIdU' stk uid_u = do
insts <- T.forM insts_u $ convertModuleU' (extendMooEnv stk u)
return (IndefFullUnitId cid insts)
convertModuleU' :: MooEnv -> ModuleU s -> UnifyM s IndefModule
convertModuleU' :: MooEnv -> ModuleU s -> UnifyM s OpenModule
convertModuleU' stk mod_u = do
mod <- liftST $ UnionFind.find mod_u
case mod of
ModuleVarU mod_name -> return (IndefModuleVar mod_name)
ModuleVarU mod_name -> return (OpenModuleVar mod_name)
ModuleU uid_u mod_name -> do
uid <- convertUnitIdU' stk uid_u
return (IndefModule uid mod_name)
return (OpenModule uid mod_name)
-- Helper functions
convertUnitIdU :: UnitIdU s -> UnifyM s OpenUnitId
convertUnitIdU = convertUnitIdU' emptyMooEnv
convertModuleU :: ModuleU s -> UnifyM s IndefModule
convertModuleU :: ModuleU s -> UnifyM s OpenModule
convertModuleU = convertModuleU' emptyMooEnv
-- | An empty 'ModuleScopeU'.
......@@ -400,7 +400,7 @@ convertInclude ((uid, ModuleShape provs reqs), pid, incl@(IncludeRenaming prov_r
-- Requirement substitution.
--
-- A -> X ==> A -> <X>
let req_subst = fmap IndefModuleVar req_rename
let req_subst = fmap OpenModuleVar req_rename
uid_u <- convertUnitId (modSubst req_subst uid)
......@@ -411,7 +411,7 @@ convertInclude ((uid, ModuleShape provs reqs), pid, incl@(IncludeRenaming prov_r
--
-- A -> X ==> X -> <X>, B -> <B>
reqs_u <- convertModuleSubst . Map.fromList $
[ (k, IndefModuleVar k)
[ (k, OpenModuleVar k)
| k <- map req_rename_fn (Set.toList reqs)
]
......
......@@ -74,11 +74,11 @@ data InstalledPackageInfo
-- these parts are exactly the same as PackageDescription
sourcePackageId :: PackageId,
installedUnitId :: UnitId,
-- INVARIANT: if this package is definite, IndefModule's
-- INVARIANT: if this package is definite, OpenModule's
-- OpenUnitId directly records UnitId. If it is
-- indefinite, IndefModule is always an IndefModuleVar
-- indefinite, OpenModule is always an OpenModuleVar
-- with the same ModuleName as the key.
instantiatedWith :: [(ModuleName, IndefModule)],
instantiatedWith :: [(ModuleName, OpenModule)],
compatPackageKey :: String,
license :: License,
copyright :: String,
......@@ -93,7 +93,7 @@ data InstalledPackageInfo
-- these parts are required by an installed package only:
abiHash :: AbiHash,
exposed :: Bool,
-- INVARIANT: if the package is definite, IndefModule's
-- INVARIANT: if the package is definite, OpenModule's
-- OpenUnitId directly records UnitId.
exposedModules :: [ExposedModule],
hiddenModules :: [ModuleName],
......@@ -124,13 +124,13 @@ data InstalledPackageInfo
indefinite :: InstalledPackageInfo -> Bool
indefinite ipi =
-- TODO: optimize a little
Set.null (indefModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi)))
Set.null (openModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi)))
-- | Get the indefinite unit identity representing this package.
-- This IS NOT guaranteed to give you a substitution; for
-- instantiated packages you will get @DefiniteUnitId (installedUnitId ipi)@.
-- For indefinite libraries, however, you will correctly get
-- an @OpenUnitId@ with the appropriate 'OpenModuleSubst'.
installedOpenUnitId :: InstalledPackageInfo -> OpenUnitId
installedOpenUnitId ipi =
if indefinite ipi
......@@ -141,7 +141,7 @@ installedOpenUnitId ipi =
-- | Returns the set of module names which need to be filled for
-- an indefinite package, or the empty set if the package is definite.
requiredSignatures :: InstalledPackageInfo -> Set ModuleName
requiredSignatures ipi = indefModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi))
requiredSignatures ipi = openModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi))
installedComponentId :: InstalledPackageInfo -> ComponentId
installedComponentId ipi = unitIdComponentId (installedUnitId ipi)
......@@ -216,7 +216,7 @@ emptyInstalledPackageInfo
data ExposedModule
= ExposedModule {
exposedName :: ModuleName,
exposedReexport :: Maybe IndefModule
exposedReexport :: Maybe OpenModule
}
deriving (Eq, Generic, Read, Show)
......@@ -298,7 +298,7 @@ basicFieldDescrs =
disp parse
installedUnitId (\pk pkg -> pkg{installedUnitId=pk})
, simpleField "instantiated-with"
(dispIndefModuleSubst . Map.fromList) (fmap Map.toList parseIndefModuleSubst)
(dispOpenModuleSubst . Map.fromList) (fmap Map.toList parseOpenModuleSubst)
instantiatedWith (\iw pkg -> pkg{instantiatedWith=iw})
, simpleField "key"
dispCompatPackageKey parseCompatPackageKey
......
......@@ -667,8 +667,8 @@ moduleNameIndex index =
IPI.ExposedModule m reexport <- IPI.exposedModules pkg
case reexport of
Nothing -> return (m, [pkg])
Just (IndefModuleVar _) -> []
Just (IndefModule _ m') | m == m' -> []
Just (OpenModuleVar _) -> []
Just (OpenModule _ m') | m == m' -> []
| otherwise -> return (m', [pkg])
-- The heuristic is this: we want to prefer the original package
-- which originally exported a module. However, if a reexport
......
......@@ -83,7 +83,7 @@ data GhcOptions = GhcOptions {
-- (we need to handle backwards compatibility.)
ghcOptThisUnitId :: Flag String,
ghcOptInstantiatedWith :: [(ModuleName, IndefModule)],
ghcOptInstantiatedWith :: [(ModuleName, OpenModule)],
-- | No code? (But we turn on interface writing
ghcOptNoCode :: Flag Bool,
......
......@@ -35,7 +35,7 @@ data ComponentLocalBuildInfo
-- | Is this an indefinite component (i.e. has unfilled holes)?
componentIsIndefinite_ :: Bool,
-- | How the component was instantiated
componentInstantiatedWith :: [(ModuleName, IndefModule)],
componentInstantiatedWith :: [(ModuleName, OpenModule)],
-- | Resolved internal and external package dependencies for this component.
-- The 'BuildInfo' specifies a set of build dependencies that must be
-- satisfied in terms of version ranges. This field fixes those dependencies
......
......@@ -1269,7 +1269,7 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
shape = planPkgShape dpkg
indef_uid =
IndefFullUnitId (unitIdComponentId (installedUnitId dpkg))
(Map.fromList [ (req, IndefModuleVar req)
(Map.fromList [ (req, OpenModuleVar req)
| req <- Set.toList (modShapeRequires shape)])
planPkgShape :: ElaboratedPlanPackage -> ModuleShape
......@@ -1740,15 +1740,15 @@ instantiateInstallPlan plan =
-- NB: NOT composition
substSubst :: Map ModuleName Module
-> Map ModuleName IndefModule
-> Map ModuleName OpenModule
-> InstM (Map ModuleName Module)
substSubst subst insts = T.mapM (substModule subst) insts
substModule :: Map ModuleName Module -> IndefModule -> InstM Module
substModule subst (IndefModuleVar mod_name)
substModule :: Map ModuleName Module -> OpenModule -> InstM Module
substModule subst (OpenModuleVar mod_name)
| Just m <- Map.lookup mod_name subst = return m
| otherwise = error "substModule: non-closing substitution"
substModule subst (IndefModule uid mod_name) = do
substModule subst (OpenModule uid mod_name) = do
uid' <- substUnitId subst uid
return (Module uid' mod_name)
......
......@@ -123,7 +123,7 @@ data ElaboratedConfiguredPackage
elabUnitId :: UnitId,
elabInstantiatedWith :: Map ModuleName Module,
elabLinkedInstantiatedWith :: Map ModuleName IndefModule,
elabLinkedInstantiatedWith :: Map ModuleName OpenModule,
-- | The 'PackageId' of the originating package
elabPkgSourceId :: PackageId,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment