@@ -64,15 +64,20 @@ data ModuleImports = ModuleImports
6464    --  ^  Transitive package dependencies unioned for all imports. 
6565    } 
6666
67- --  |  For processing dependency information, we need lots of maps and sets 
68- --  of filepaths. Comparing Strings is really slow, so we work with IntMap/IntSet 
69- --  instead and only convert at the edges 
70- --  and 
67+ --  |  For processing dependency information, we need lots of maps and sets of 
68+ --  filepaths. Comparing Strings is really slow, so we work with IntMap/IntSet 
69+ --  instead and only convert at the edges. 
7170newtype  FilePathId  =  FilePathId  {  getFilePathId  ::  Int } 
7271  deriving  (Show , NFData , Eq , Ord )
7372
73+ --  |  Map from 'FilePathId' 
74+ type  FilePathIdMap  =  IntMap 
75+ 
76+ --  |  Set of 'FilePathId's 
77+ type  FilePathIdSet  =  IntSet 
78+ 
7479data  PathIdMap  =  PathIdMap 
75-   {  idToPathMap  ::  ! (IntMap  ArtifactsLocation )
80+   {  idToPathMap  ::  ! (FilePathIdMap  ArtifactsLocation )
7681  , pathToIdMap  ::  ! (HashMap  NormalizedFilePath  FilePathId )
7782  } 
7883  deriving  (Show , Generic )
@@ -109,16 +114,14 @@ idToPath pathIdMap filePathId = artifactFilePath $ idToModLocation pathIdMap fil
109114idToModLocation  ::  PathIdMap  ->  FilePathId  ->  ArtifactsLocation 
110115idToModLocation PathIdMap {idToPathMap} (FilePathId  id ) =  idToPathMap IntMap. !id 
111116
112- 
113- type  BootIdMap  =  IntMap  FilePathId 
117+ type  BootIdMap  =  FilePathIdMap  FilePathId 
114118
115119insertBootId  ::  FilePathId  ->  FilePathId  ->  BootIdMap  ->  BootIdMap 
116120insertBootId k =  IntMap. insert (getFilePathId k)
117121
118- 
119122--  |  Unprocessed results that we find by following imports recursively. 
120123data  RawDependencyInformation  =  RawDependencyInformation 
121-     {  rawImports  ::  ! (IntMap  (Either ModuleParseError  ModuleImports ))
124+     {  rawImports  ::  ! (FilePathIdMap  (Either ModuleParseError  ModuleImports ))
122125    , rawPathIdMap  ::  ! PathIdMap 
123126    --  The rawBootMap maps the FilePathId of a hs-boot file to its
124127    --  corresponding hs file. It is used when topologically sorting as we
@@ -127,23 +130,24 @@ data RawDependencyInformation = RawDependencyInformation
127130    , rawBootMap  ::  ! BootIdMap 
128131    } 
129132
130- pkgDependencies  ::  RawDependencyInformation  ->  IntMap  (Set  InstalledUnitId )
133+ pkgDependencies  ::  RawDependencyInformation  ->  FilePathIdMap  (Set  InstalledUnitId )
131134pkgDependencies RawDependencyInformation {.. } = 
132135    IntMap. map  (either  (const  Set. empty) packageImports) rawImports
133136
134137data  DependencyInformation  = 
135138  DependencyInformation 
136-     {  depErrorNodes  ::  ! (IntMap  (NonEmpty  NodeError ))
139+     {  depErrorNodes  ::  ! (FilePathIdMap  (NonEmpty  NodeError ))
137140    --  ^  Nodes that cannot be processed correctly. 
138-     , depModuleNames  ::  ! (IntMap  ShowableModuleName )
139-     , depModuleDeps  ::  ! (IntMap   IntSet )
141+     , depModuleNames  ::  ! (FilePathIdMap  ShowableModuleName )
142+     , depModuleDeps  ::  ! (FilePathIdMap   FilePathIdSet )
140143    --  ^  For a non-error node, this contains the set of module immediate dependencies 
141144    --  in the same package.
142-     , depPkgDeps  ::  ! (IntMap  (Set  InstalledUnitId ))
145+     , depPkgDeps  ::  ! (FilePathIdMap  (Set  InstalledUnitId ))
143146    --  ^  For a non-error node, this contains the set of immediate pkg deps. 
144147    , depPathIdMap  ::  ! PathIdMap 
145-     --  ^  Map from hs-boot file  to the corresponding hs file  
148+     --  ^  Map from FilePath  to FilePathId  
146149    , depBootMap  ::  ! BootIdMap 
150+     --  ^  Map from hs-boot file to the corresponding hs file 
147151    }  deriving  (Show , Generic )
148152
149153newtype  ShowableModuleName  = 
@@ -243,7 +247,7 @@ processDependencyInformation rawDepInfo@RawDependencyInformation{..} =
243247--  2. Mark each node that has a parse error as an error node. 
244248--  3. Mark each node whose immediate children could not be located as an error. 
245249--  4. Recursively propagate errors to parents if they are not already error nodes. 
246- buildResultGraph  ::  IntMap  (Either ModuleParseError  ModuleImports ) ->  IntMap  NodeResult 
250+ buildResultGraph  ::  FilePathIdMap  (Either ModuleParseError  ModuleImports ) ->  FilePathIdMap  NodeResult 
247251buildResultGraph g =  propagatedErrors
248252    where 
249253        sccs =  stronglyConnComp (graphEdges g)
@@ -290,7 +294,7 @@ buildResultGraph g = propagatedErrors
290294            Right ModuleImports {moduleImports} -> 
291295              fmap  fst  $  find (\ (_, resolvedImp) ->  resolvedImp ==  Just  importedFile) moduleImports
292296
293- graphEdges  ::  IntMap  (Either ModuleParseError  ModuleImports ) ->  [(FilePathId , FilePathId , [FilePathId ])]
297+ graphEdges  ::  FilePathIdMap  (Either ModuleParseError  ModuleImports ) ->  [(FilePathId , FilePathId , [FilePathId ])]
294298graphEdges g = 
295299  map  (\ (k, v) ->  (FilePathId  k, FilePathId  k, deps v)) $  IntMap. toList g
296300  where  deps ::  Either e  ModuleImports  ->  [FilePathId ]
0 commit comments