Skip to content

Commit cf8c693

Browse files
committed
Minor reformatting
1 parent c3b73d7 commit cf8c693

File tree

1 file changed

+66
-63
lines changed

1 file changed

+66
-63
lines changed

src/Stack/Build/Source.hs

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,48 @@ module Stack.Build.Source
1414
, hashSourceMapData
1515
) where
1616

17-
import Conduit ( ZipSink (..), withSourceFile )
18-
import Data.ByteString.Builder ( toLazyByteString )
19-
import qualified Data.List as L
20-
import qualified Data.Map as Map
21-
import qualified Data.Map.Strict as M
22-
import qualified Data.Set as Set
23-
import qualified Distribution.PackageDescription as C
24-
import qualified Pantry.SHA256 as SHA256
25-
import Stack.Build.Cache ( tryGetBuildCache )
26-
import Stack.Build.Haddock ( shouldHaddockDeps )
27-
import Stack.Package ( resolvePackage )
28-
import Stack.Prelude
29-
import Stack.SourceMap
30-
( DumpedGlobalPackage, checkFlagsUsedThrowing
31-
, getCompilerInfo, immutableLocSha, mkProjectPackage
32-
, pruneGlobals
33-
)
34-
import Stack.Types.Build ( FlagSource (..) )
35-
import Stack.Types.Config
36-
( ApplyCLIFlag (..), ApplyGhcOptions (..)
37-
, BuildConfig (..), BuildOpts (..), BuildOptsCLI (..)
38-
, CabalConfigKey (..), Config (..), Curator (..)
39-
, HasBuildConfig (..), HasCompiler, HasConfig (..)
40-
, HasEnvConfig (..), HasPlatform (..), HasSourceMap (..)
41-
, ProjectPackage (..), TestOpts (..)
42-
, actualCompilerVersionL, buildOptsL, envConfigSourceMap
43-
, getCompilerPath, ppGPD, ppRoot
44-
)
45-
import Stack.Types.NamedComponent
46-
( NamedComponent (..), isCInternalLib )
47-
import Stack.Types.Package
48-
( FileCacheInfo (..), LocalPackage (..), Package (..)
49-
, PackageConfig (..), PackageLibraries (..)
50-
, dotCabalGetPath, memoizeRefWith, runMemoizedWith
51-
)
52-
import Stack.Types.PackageFile ( PackageWarning, getPackageFiles )
53-
import Stack.Types.SourceMap
54-
( CommonPackage (..), DepPackage (..), SMActual (..)
55-
, SMTargets (..), SourceMap (..), SourceMapHash (..)
56-
, Target (..)
57-
)
58-
import System.FilePath ( takeFileName )
59-
import System.IO.Error ( isDoesNotExistError )
17+
import Conduit ( ZipSink (..), withSourceFile )
18+
import Data.ByteString.Builder ( toLazyByteString )
19+
import qualified Data.List as L
20+
import qualified Data.Map as Map
21+
import qualified Data.Map.Strict as M
22+
import qualified Data.Set as Set
23+
import qualified Distribution.PackageDescription as C
24+
import qualified Pantry.SHA256 as SHA256
25+
import Stack.Build.Cache ( tryGetBuildCache )
26+
import Stack.Build.Haddock ( shouldHaddockDeps )
27+
import Stack.Package ( resolvePackage )
28+
import Stack.Prelude
29+
import Stack.SourceMap
30+
( DumpedGlobalPackage, checkFlagsUsedThrowing
31+
, getCompilerInfo, immutableLocSha, mkProjectPackage
32+
, pruneGlobals
33+
)
34+
import Stack.Types.Build ( FlagSource (..) )
35+
import Stack.Types.Config
36+
( ApplyCLIFlag (..), ApplyGhcOptions (..), BuildConfig (..)
37+
, BuildOpts (..), BuildOptsCLI (..), CabalConfigKey (..)
38+
, Config (..), Curator (..), HasBuildConfig (..), HasCompiler
39+
, HasConfig (..), HasEnvConfig (..), HasPlatform (..)
40+
, HasSourceMap (..), ProjectPackage (..), TestOpts (..)
41+
, actualCompilerVersionL, buildOptsL, envConfigSourceMap
42+
, getCompilerPath, ppGPD, ppRoot
43+
)
44+
import Stack.Types.NamedComponent
45+
( NamedComponent (..), isCInternalLib )
46+
import Stack.Types.Package
47+
( FileCacheInfo (..), LocalPackage (..), Package (..)
48+
, PackageConfig (..), PackageLibraries (..)
49+
, dotCabalGetPath, memoizeRefWith, runMemoizedWith
50+
)
51+
import Stack.Types.PackageFile ( PackageWarning, getPackageFiles )
52+
import Stack.Types.SourceMap
53+
( CommonPackage (..), DepPackage (..), SMActual (..)
54+
, SMTargets (..), SourceMap (..), SourceMapHash (..)
55+
, Target (..)
56+
)
57+
import System.FilePath ( takeFileName )
58+
import System.IO.Error ( isDoesNotExistError )
6059

6160
-- | loads and returns project packages
6261
projectLocalPackages :: HasEnvConfig env => RIO env [LocalPackage]
@@ -162,10 +161,10 @@ hashSourceMapData boptsCli sm = do
162161
compilerInfo <- getCompilerInfo
163162
immDeps <- forM (Map.elems (smDeps sm)) depPackageHashableContent
164163
bc <- view buildConfigL
165-
let -- extra bytestring specifying GHC options supposed to be applied to
166-
-- GHC boot packages so we'll have different hashes when bare
167-
-- resolver 'ghc-X.Y.Z' is used, no extra-deps and e.g. user wants builds
168-
-- with profiling or without
164+
let -- extra bytestring specifying GHC options supposed to be applied to GHC
165+
-- boot packages so we'll have different hashes when bare resolver
166+
-- 'ghc-X.Y.Z' is used, no extra-deps and e.g. user wants builds with
167+
-- profiling or without
169168
bootGhcOpts = map display (generalGhcOptions bc boptsCli False False)
170169
hashedContent =
171170
toLazyByteString $ compilerPath
@@ -287,7 +286,10 @@ loadLocalPackage pp = do
287286
let common = ppCommon pp
288287
bopts <- view buildOptsL
289288
mcurator <- view $ buildConfigL.to bcCurator
290-
config <- getPackageConfig (cpFlags common) (cpGhcOptions common) (cpCabalConfigOpts common)
289+
config <- getPackageConfig
290+
(cpFlags common)
291+
(cpGhcOptions common)
292+
(cpCabalConfigOpts common)
291293
gpkg <- ppGPD pp
292294
let name = cpName common
293295
mtarget = M.lookup name (smtTargets $ smTargets sm)
@@ -313,10 +315,9 @@ loadLocalPackage pp = do
313315
-- See https://github.com/commercialhaskell/stack/issues/2862
314316
isWanted = case mtarget of
315317
Nothing -> False
316-
-- FIXME: When issue #1406 ("stack 0.1.8 lost ability to
317-
-- build individual executables or library") is resolved,
318-
-- 'hasLibrary' is only relevant if the library is
319-
-- part of the target spec.
318+
-- FIXME: When issue #1406 ("stack 0.1.8 lost ability to build
319+
-- individual executables or library") is resolved, 'hasLibrary' is only
320+
-- relevant if the library is part of the target spec.
320321
Just _ ->
321322
let hasLibrary =
322323
case packageLibraries pkg of
@@ -326,11 +327,13 @@ loadLocalPackage pp = do
326327
|| not (Set.null nonLibComponents)
327328
|| not (Set.null $ packageInternalLibraries pkg)
328329

329-
filterSkippedComponents = Set.filter (not . (`elem` boptsSkipComponents bopts))
330+
filterSkippedComponents =
331+
Set.filter (not . (`elem` boptsSkipComponents bopts))
330332

331-
(exes, tests, benches) = (filterSkippedComponents exeCandidates,
332-
filterSkippedComponents testCandidates,
333-
filterSkippedComponents benchCandidates)
333+
(exes, tests, benches) = ( filterSkippedComponents exeCandidates
334+
, filterSkippedComponents testCandidates
335+
, filterSkippedComponents benchCandidates
336+
)
334337

335338
nonLibComponents = toComponents exes tests benches
336339

@@ -374,7 +377,8 @@ loadLocalPackage pp = do
374377

375378
let dirtyFiles = do
376379
checkCacheResults' <- checkCacheResults
377-
let allDirtyFiles = Set.unions $ map (\(_, (x, _)) -> x) checkCacheResults'
380+
let allDirtyFiles =
381+
Set.unions $ map (\(_, (x, _)) -> x) checkCacheResults'
378382
pure $
379383
if not (Set.null allDirtyFiles)
380384
then let tryStripPrefix y =
@@ -484,12 +488,11 @@ getPackageFilesForTargets pkg cabalFP nonLibComponents = do
484488
let necessaryComponents =
485489
Set.insert CLib $ Set.filter isCInternalLib (M.keysSet components')
486490
components = necessaryComponents `Set.union` nonLibComponents
487-
componentsFiles =
488-
M.map
489-
(\files ->
490-
Set.union otherFiles (Set.map dotCabalGetPath $ Set.fromList files)
491-
)
492-
$ M.filterWithKey (\component _ -> component `elem` components) compFiles
491+
componentsFiles = M.map
492+
(\files ->
493+
Set.union otherFiles (Set.map dotCabalGetPath $ Set.fromList files)
494+
)
495+
$ M.filterWithKey (\component _ -> component `elem` components) compFiles
493496
pure (componentsFiles, warnings)
494497

495498
-- | Get file digest, if it exists

0 commit comments

Comments
 (0)