mirror of
https://github.com/github/semantic.git
synced 2025-01-03 04:51:57 +03:00
Split a package body type out of Package.
This commit is contained in:
parent
056a23a949
commit
9266439e7f
@ -186,8 +186,8 @@ evaluatePackage :: ( Effectful m
|
||||
)
|
||||
=> Package term
|
||||
-> m effects [value]
|
||||
evaluatePackage p = pushOrigin (packageOrigin p) (localModuleTable (<> packageModules p)
|
||||
(traverse evaluateEntryPoint (ModuleTable.toPairs (packageEntryPoints p))))
|
||||
evaluatePackage p = pushOrigin (packageOrigin p) (localModuleTable (<> packageModules (packageBody p))
|
||||
(traverse evaluateEntryPoint (ModuleTable.toPairs (packageEntryPoints (packageBody p)))))
|
||||
where evaluateEntryPoint (m, sym) = do
|
||||
(_, v) <- require m
|
||||
maybe (pure v) ((`call` []) <=< variable) sym
|
||||
|
@ -18,14 +18,18 @@ newtype Version = Version { versionString :: String }
|
||||
|
||||
-- | A package represents the unit of dependency, i.e. something which can depend upon, or be depended upon by, other packages. Packages have modules and may have entry points from which evaluation can proceed.
|
||||
data Package term = Package
|
||||
{ packageInfo :: PackageInfo
|
||||
, packageModules :: ModuleTable [Module term]
|
||||
{ packageInfo :: PackageInfo
|
||||
, packageBody :: PackageBody term
|
||||
}
|
||||
deriving (Eq, Functor, Ord, Show)
|
||||
|
||||
data PackageBody term = PackageBody
|
||||
{ packageModules :: ModuleTable [Module term]
|
||||
, packageEntryPoints :: ModuleTable (Maybe Name)
|
||||
}
|
||||
deriving (Eq, Functor, Ord, Show)
|
||||
|
||||
|
||||
fromModules :: [Module term] -> Package term
|
||||
fromModules [] = Package (PackageInfo Nothing Nothing) mempty mempty
|
||||
fromModules (m:ms) = Package (PackageInfo Nothing Nothing) (ModuleTable.fromModules (m:ms)) entryPoints
|
||||
fromModules [] = Package (PackageInfo Nothing Nothing) (PackageBody mempty mempty)
|
||||
fromModules (m:ms) = Package (PackageInfo Nothing Nothing) (PackageBody (ModuleTable.fromModules (m:ms)) entryPoints)
|
||||
where entryPoints = ModuleTable.singleton (moduleName (moduleInfo m)) Nothing
|
||||
|
Loading…
Reference in New Issue
Block a user