@@ -36,20 +36,20 @@ import Module
3636
3737-- | Unprocessed results that we get from following all imports recursively starting from a module.
3838data RawDependencyInformation = RawDependencyInformation
39− { moduleDependencies :: Map FilePath (Either ModuleParseError [(Located ModuleName, Maybe FilePath)])
40− , pkgDependencies :: Map FilePath (Set InstalledUnitId)
39+ { moduleDependencies :: Map NormalizedFilePath (Either ModuleParseError [(Located ModuleName, Maybe NormalizedFilePath)])
40+ , pkgDependencies :: Map NormalizedFilePath (Set InstalledUnitId)
4141 -- ^ Transitive dependencies on pkgs of this file, i.e. immidiate package dependencies and the
4242 -- transitive package dependencies of those packages.
4343 }
4444
4545data DependencyInformation =
4646 DependencyInformation
47− { depErrorNodes :: Map FilePath (NonEmpty NodeError)
47+ { depErrorNodes :: Map NormalizedFilePath (NonEmpty NodeError)
4848 -- ^ Nodes that cannot be processed correctly.
49− , depModuleDeps :: Map FilePath (Set FilePath)
49+ , depModuleDeps :: Map NormalizedFilePath (Set NormalizedFilePath)
5050 -- ^ For a non-error node, this contains the set of module immediate dependencies
5151 -- in the same package.
52− , depPkgDeps :: Map FilePath (Set InstalledUnitId)
52+ , depPkgDeps :: Map NormalizedFilePath (Set InstalledUnitId)
5353 -- ^ For a non-error node, this contains the set of immediate pkg deps.
5454 } deriving (Show, Generic)
5555
@@ -69,7 +69,7 @@ instance NFData LocateError
6969
7070-- | An error attached to a node in the dependency graph.
7171data NodeError
72− = PartOfCycle (Located ModuleName) [FilePath]
72+ = PartOfCycle (Located ModuleName) [NormalizedFilePath]
7373 -- ^ This module is part of an import cycle. The module name corresponds
7474 -- to the import that enters the cycle starting from this module.
7575 -- The list of filepaths represents the elements
@@ -94,10 +94,12 @@ instance NFData NodeError where
9494-- `ErrorNode`. Otherwise it is a `SuccessNode`.
9595data NodeResult
9696 = ErrorNode (NonEmpty NodeError)
97− | SuccessNode [(Located ModuleName, FilePath)]
97+ | SuccessNode [(Located ModuleName, NormalizedFilePath)]
9898 deriving Show
9999
100−partitionNodeResults :: [(a, NodeResult)] -> ([(a, NonEmpty NodeError)], [(a, [(Located ModuleName, FilePath)])])
100+partitionNodeResults
101+ :: [(a, NodeResult)]
102+ -> ([(a, NonEmpty NodeError)], [(a, [(Located ModuleName, NormalizedFilePath)])])
101103partitionNodeResults = partitionEithers . map f
102104 where f (a, ErrorNode errs) = Left (a, errs)
103105 f (a, SuccessNode imps) = Right (a, imps)
@@ -116,7 +118,7 @@ processDependencyInformation rawResults =
116118 , depPkgDeps = pkgDependencies rawResults
117119 }
118120 where resultGraph = buildResultGraph rawResults
119− successEdges :: [(FilePath, FilePath, [FilePath])]
121+ successEdges :: [(NormalizedFilePath, NormalizedFilePath, [NormalizedFilePath])]
120122 successEdges = map (\(k,ks) -> (k,k,ks)) $ MS.toList $
121123 MS.map (map snd) $ MS.mapMaybe successNode resultGraph
122124 moduleDeps =
@@ -131,22 +133,22 @@ processDependencyInformation rawResults =
131133-- 2. Mark each node that has a parse error as an error node.
132134-- 3. Mark each node whose immediate children could not be located as an error.
133135-- 4. Recursively propagate errors to parents if they are not already error nodes.
134−buildResultGraph :: RawDependencyInformation -> Map FilePath NodeResult
136+buildResultGraph :: RawDependencyInformation -> Map NormalizedFilePath NodeResult
135137buildResultGraph g = propagatedErrors
136138 where
137139 sccs = stronglyConnComp (graphEdges g)
138140 (_, cycles) = partitionSCC sccs
139− cycleErrors :: Map FilePath NodeResult
141+ cycleErrors :: Map NormalizedFilePath NodeResult
140142 cycleErrors = MS.unionsWith (<>) $ map errorsForCycle cycles
141− errorsForCycle :: [FilePath] -> Map FilePath NodeResult
143+ errorsForCycle :: [NormalizedFilePath] -> Map NormalizedFilePath NodeResult
142144 errorsForCycle files =
143145 MS.fromListWith (<>) (concatMap (cycleErrorsForFile files) files)
144− cycleErrorsForFile :: [FilePath] -> FilePath -> [(FilePath,NodeResult)]
146+ cycleErrorsForFile :: [NormalizedFilePath] -> NormalizedFilePath -> [(NormalizedFilePath,NodeResult)]
145147 cycleErrorsForFile cycle f =
146148 let entryPoints = mapMaybe (findImport f) cycle
147149 in map (\imp -> (f, ErrorNode (PartOfCycle imp cycle :| []))) entryPoints
148150 otherErrors = MS.map otherErrorsForFile (moduleDependencies g)
149− otherErrorsForFile :: Either ModuleParseError [(Located ModuleName, Maybe FilePath)] -> NodeResult
151+ otherErrorsForFile :: Either ModuleParseError [(Located ModuleName, Maybe NormalizedFilePath)] -> NodeResult
150152 otherErrorsForFile (Left err) = ErrorNode (ParseError err :| [])
151153 otherErrorsForFile (Right imports) =
152154 let toEither (imp, Nothing) = Left imp
@@ -171,17 +173,17 @@ buildResultGraph g = propagatedErrors
171173 in case nonEmpty errs of
172174 Nothing -> n
173175 Just errs' -> ErrorNode (NonEmpty.map (ParentOfErrorNode . fst) errs')
174− findImport :: FilePath -> FilePath -> Maybe (Located ModuleName)
176+ findImport :: NormalizedFilePath -> NormalizedFilePath -> Maybe (Located ModuleName)
175177 findImport file importedFile =
176178 case moduleDependencies g MS.! file of
177179 Left _ -> error "Tried to call findImport on a module with a parse error"
178180 Right imports ->
179181 fmap fst $ find (\(_, resolvedImp) -> resolvedImp == Just importedFile) imports
180182
181−graphEdges :: RawDependencyInformation -> [(FilePath, FilePath, [FilePath])]
183+graphEdges :: RawDependencyInformation -> [(NormalizedFilePath, NormalizedFilePath, [NormalizedFilePath])]
182184graphEdges g =
183185 map (\(k, ks) -> (k, k, ks)) $ MS.toList $ MS.map deps $ moduleDependencies g
184− where deps :: Either e [(i, Maybe FilePath)] -> [FilePath]
186+ where deps :: Either e [(i, Maybe NormalizedFilePath)] -> [NormalizedFilePath]
185187 deps (Left _) = []
186188 deps (Right imports) = mapMaybe snd imports
187189
@@ -190,17 +192,17 @@ partitionSCC (CyclicSCC xs:rest) = second (xs:) $ partitionSCC rest
190192partitionSCC (AcyclicSCC x:rest) = first (x:) $ partitionSCC rest
191193partitionSCC [] = ([], [])
192194
193−transitiveDeps :: DependencyInformation -> FilePath -> Maybe TransitiveDependencies
195+transitiveDeps :: DependencyInformation -> NormalizedFilePath -> Maybe TransitiveDependencies
194196transitiveDeps DependencyInformation{..} f = do
195197 reachableVs <- Set.delete f . Set.fromList . map (fst3 . fromVertex) . reachable g <$> toVertex f
196198 let transitiveModuleDeps = filter (\v -> v `Set.member` reachableVs) $ map (fst3 . fromVertex) vs
197199 let transitivePkgDeps = Set.toList $ foldMap (\f -> MS.findWithDefault Set.empty f depPkgDeps) (f : transitiveModuleDeps)
198− pure $ TransitiveDependencies {..}
200+ pure TransitiveDependencies {..}
199201 where (g, fromVertex, toVertex) = graphFromEdges (map (\(f, fs) -> (f, f, Set.toList fs)) $ MS.toList depModuleDeps)
200202 vs = topSort g
201203
202204data TransitiveDependencies = TransitiveDependencies
203− { transitiveModuleDeps :: [FilePath]
205+ { transitiveModuleDeps :: [NormalizedFilePath]
204206 -- ^ Transitive module dependencies in topological order.
205207 -- The module itself is not included.
206208 , transitivePkgDeps :: [InstalledUnitId]