1
1
mirror of https://github.com/github/semantic.git synced 2025-01-06 23:46:21 +03:00

Split PackageInfo into a new datatype.

This commit is contained in:
Rob Rix 2018-03-30 19:46:25 -04:00
parent 37535b1823
commit 0ebf115fae
2 changed files with 10 additions and 5 deletions

View File

@ -6,9 +6,14 @@ import Data.Abstract.ModuleTable as ModuleTable
type PackageName = Name
data PackageInfo = PackageInfo
{ packageName :: Maybe PackageName
, packageVersion :: Maybe Version
}
deriving (Eq, Ord, Show)
data Package term = Package
{ packageName :: Maybe PackageName
, packageVersion :: Maybe Version
{ packageInfo :: PackageInfo
, packageModules :: ModuleTable [Module term]
, packageEntryPoints :: ModuleTable (Maybe Name)
}
@ -19,6 +24,6 @@ newtype Version = Version { versionString :: String }
fromModules :: [Module term] -> Package term
fromModules [] = Package Nothing Nothing mempty mempty
fromModules (m:ms) = Package Nothing Nothing (ModuleTable.fromModules (m:ms)) entryPoints
fromModules [] = Package (PackageInfo Nothing Nothing) mempty mempty
fromModules (m:ms) = Package (PackageInfo Nothing Nothing) (ModuleTable.fromModules (m:ms)) entryPoints
where entryPoints = ModuleTable.singleton (moduleName (moduleInfo m)) Nothing

View File

@ -181,7 +181,7 @@ parseFiles parser paths = traverse (parseFile parser (Just (dropFileName (head p
parsePackage :: PackageName -> Parser term -> [FilePath] -> IO (Package term)
parsePackage name parser files = setName . Package.fromModules <$> parseFiles parser files
where setName p = p { Package.packageName = Just name }
where setName p = p { packageInfo = PackageInfo (Just name) Nothing }
-- Read a file from the filesystem into a Blob.