Skip to content

Add more type signatures #6702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Stack/ComponentFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,19 @@ stackBenchmarkFiles ::
stackBenchmarkFiles bench =
resolveComponentFiles (CBench bench.name) build names
where
names :: [DotCabalDescriptor]
names = bnames <> exposed

exposed :: [DotCabalDescriptor]
exposed =
case bench.interface of
BenchmarkExeV10 _ fp -> [DotCabalMain fp]
BenchmarkUnsupported _ -> []

bnames :: [DotCabalDescriptor]
bnames = map DotCabalModule build.otherModules

build :: StackBuildInfo
build = bench.buildInfo

-- | Get all files referenced by the test.
Expand All @@ -96,13 +103,20 @@ stackTestSuiteFiles ::
stackTestSuiteFiles test =
resolveComponentFiles (CTest test.name) build names
where
names :: [DotCabalDescriptor]
names = bnames <> exposed

exposed :: [DotCabalDescriptor]
exposed =
case test.interface of
TestSuiteExeV10 _ fp -> [DotCabalMain fp]
TestSuiteLibV09 _ mn -> [DotCabalModule mn]
TestSuiteUnsupported _ -> []

bnames :: [DotCabalDescriptor]
bnames = map DotCabalModule build.otherModules

build :: StackBuildInfo
build = test.buildInfo

-- | Get all files referenced by the executable.
Expand All @@ -112,7 +126,10 @@ stackExecutableFiles ::
stackExecutableFiles exe =
resolveComponentFiles (CExe exe.name) build names
where
build :: StackBuildInfo
build = exe.buildInfo

names :: [DotCabalDescriptor]
names =
map DotCabalModule build.otherModules ++ [DotCabalMain exe.modulePath]

Expand All @@ -124,13 +141,24 @@ stackLibraryFiles ::
stackLibraryFiles lib =
resolveComponentFiles componentName build names
where
componentRawName :: StackUnqualCompName
componentRawName = lib.name

componentName :: NamedComponent
componentName
| componentRawName == emptyCompName = CLib
| otherwise = CSubLib componentRawName

build :: StackBuildInfo
build = lib.buildInfo

names :: [DotCabalDescriptor]
names = bnames ++ exposed

exposed :: [DotCabalDescriptor]
exposed = map DotCabalModule lib.exposedModules

bnames :: [DotCabalDescriptor]
bnames = map DotCabalModule build.otherModules

-- | Get all files referenced by the component.
Expand All @@ -154,6 +182,7 @@ resolveComponentFiles component build names = do
cfiles <- buildOtherSources build
pure (component, ComponentFile modules (files <> cfiles) warnings)
where
autogenDirs :: RIO GetPackageFileContext [Path Abs Dir]
autogenDirs = do
distDir <- asks (.distDir)
let compDir = componentAutogenDir component distDir
Expand Down
5 changes: 5 additions & 0 deletions src/Stack/PackageFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ resolveGlobFiles ::
resolveGlobFiles cabalFileVersion =
fmap (S.fromList . concatMap catMaybes) . mapM resolve
where
resolve :: FilePath -> RIO GetPackageFileContext [Maybe (Path Abs File)]
resolve name =
if '*' `elem` name
then explode name
else fmap pure (resolveFileOrWarn name)

explode :: FilePath -> RIO GetPackageFileContext [Maybe (Path Abs File)]
explode name = do
dir <- asks (parent . (.file))
names <- matchDirFileGlob' (toFilePath dir) name
mapM resolveFileOrWarn names

matchDirFileGlob' :: FilePath -> FilePath -> RIO GetPackageFileContext [FilePath]
matchDirFileGlob' dir glob =
catch
(liftIO (matchDirFileGlob minBound cabalFileVersion dir glob))
Expand Down