Skip to content

Commit a7cc488

Browse files
authored
Merge pull request #6138 from commercialhaskell/refactor
Light reformatting
2 parents 26e1c5e + 3b2aef0 commit a7cc488

File tree

1 file changed

+105
-91
lines changed

1 file changed

+105
-91
lines changed

src/Stack/Setup.hs

Lines changed: 105 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,9 +1449,9 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla
14491449
<> display flavour
14501450
<> "` flavour. It can take a long time (more than one hour)..."
14511451

1452-
-- We need to provide an absolute path to the script since
1453-
-- the process package only sets working directory _after_
1454-
-- discovering the executable
1452+
-- We need to provide an absolute path to the script since the process
1453+
-- package only sets working directory _after_ discovering the
1454+
-- executable.
14551455
proc (toFilePath hadrianPath) hadrianArgs runProcess_
14561456

14571457
-- find the bindist and install it
@@ -1676,7 +1676,8 @@ sysRelease =
16761676
ensureDockerStackExe :: HasConfig env => Platform -> RIO env (Path Abs File)
16771677
ensureDockerStackExe containerPlatform = do
16781678
config <- view configL
1679-
containerPlatformDir <- runReaderT platformOnlyRelDir (containerPlatform,PlatformVariantNone)
1679+
containerPlatformDir <-
1680+
runReaderT platformOnlyRelDir (containerPlatform,PlatformVariantNone)
16801681
let programsPath = configLocalProgramsBase config </> containerPlatformDir
16811682
tool = Tool (PackageIdentifier (mkPackageName "stack") stackVersion)
16821683
stackExeDir <- installDir programsPath tool
@@ -1700,7 +1701,7 @@ ensureDockerStackExe containerPlatform = do
17001701

17011702
-- | Get all executables on the path that might match the wanted compiler
17021703
sourceSystemCompilers ::
1703-
(HasProcessContext env, HasLogFunc env)
1704+
(HasLogFunc env, HasProcessContext env)
17041705
=> WantedCompiler
17051706
-> ConduitT i (Path Abs File) (RIO env) ()
17061707
sourceSystemCompilers wanted = do
@@ -1742,10 +1743,11 @@ getSetupInfo = do
17421743
logJSONWarnings urlOrFile warnings
17431744
pure si
17441745

1745-
getInstalledTool :: [Tool] -- ^ already installed
1746-
-> PackageName -- ^ package to find
1747-
-> (Version -> Bool) -- ^ which versions are acceptable
1748-
-> Maybe Tool
1746+
getInstalledTool ::
1747+
[Tool] -- ^ already installed
1748+
-> PackageName -- ^ package to find
1749+
-> (Version -> Bool) -- ^ which versions are acceptable
1750+
-> Maybe Tool
17491751
getInstalledTool installed name goodVersion = Tool <$>
17501752
maximumByMaybe (comparing pkgVersion) (filterTools name goodVersion installed)
17511753

@@ -1774,26 +1776,30 @@ downloadAndInstallTool programsDir downloadInfo tool installer = do
17741776
liftIO $ ignoringAbsence (removeDirRecur tempDir)
17751777
pure tool
17761778

1777-
downloadAndInstallCompiler :: (HasBuildConfig env, HasGHCVariant env)
1778-
=> CompilerBuild
1779-
-> SetupInfo
1780-
-> WantedCompiler
1781-
-> VersionCheck
1782-
-> Maybe String
1783-
-> RIO env Tool
1779+
downloadAndInstallCompiler ::
1780+
(HasBuildConfig env, HasGHCVariant env)
1781+
=> CompilerBuild
1782+
-> SetupInfo
1783+
-> WantedCompiler
1784+
-> VersionCheck
1785+
-> Maybe String
1786+
-> RIO env Tool
17841787
downloadAndInstallCompiler ghcBuild si wanted@(WCGhc version) versionCheck mbindistURL = do
17851788
ghcVariant <- view ghcVariantL
17861789
(selectedVersion, downloadInfo) <- case mbindistURL of
17871790
Just bindistURL -> do
17881791
case ghcVariant of
17891792
GHCCustom _ -> pure ()
17901793
_ -> prettyThrowM RequireCustomGHCVariant
1791-
pure (version, GHCDownloadInfo mempty mempty DownloadInfo
1792-
{ downloadInfoUrl = T.pack bindistURL
1793-
, downloadInfoContentLength = Nothing
1794-
, downloadInfoSha1 = Nothing
1795-
, downloadInfoSha256 = Nothing
1796-
})
1794+
pure
1795+
( version
1796+
, GHCDownloadInfo mempty mempty DownloadInfo
1797+
{ downloadInfoUrl = T.pack bindistURL
1798+
, downloadInfoContentLength = Nothing
1799+
, downloadInfoSha1 = Nothing
1800+
, downloadInfoSha256 = Nothing
1801+
}
1802+
)
17971803
_ -> do
17981804
ghcKey <- getGhcKey ghcBuild
17991805
case Map.lookup ghcKey $ siGHCs si of
@@ -1812,8 +1818,8 @@ downloadAndInstallCompiler ghcBuild si wanted@(WCGhc version) versionCheck mbind
18121818
GHCStandard -> []
18131819
v -> ["(" <> fromString (ghcVariantName v) <> ")"]
18141820
<> case ghcBuild of
1815-
CompilerBuildStandard -> []
1816-
b -> ["(" <> fromString (compilerBuildName b) <> ")"]
1821+
CompilerBuildStandard -> []
1822+
b -> ["(" <> fromString (compilerBuildName b) <> ")"]
18171823
<> [ flow "to an isolated location. This will not interfere with any \
18181824
\system-level installation."
18191825
]
@@ -1831,13 +1837,14 @@ downloadAndInstallCompiler _ _ WCGhcjs{} _ _ = throwIO GhcjsNotSupported
18311837
downloadAndInstallCompiler _ _ WCGhcGit{} _ _ =
18321838
prettyThrowIO DownloadAndInstallCompilerError
18331839

1834-
getWantedCompilerInfo :: (Ord k, MonadThrow m)
1835-
=> Text
1836-
-> VersionCheck
1837-
-> WantedCompiler
1838-
-> (k -> ActualCompiler)
1839-
-> Map k a
1840-
-> m (k, a)
1840+
getWantedCompilerInfo ::
1841+
(Ord k, MonadThrow m)
1842+
=> Text
1843+
-> VersionCheck
1844+
-> WantedCompiler
1845+
-> (k -> ActualCompiler)
1846+
-> Map k a
1847+
-> m (k, a)
18411848
getWantedCompilerInfo key versionCheck wanted toCV pairs_ =
18421849
case mpair of
18431850
Just pair -> pure pair
@@ -1856,13 +1863,13 @@ getWantedCompilerInfo key versionCheck wanted toCV pairs_ =
18561863

18571864
-- | Download and install the first available compiler build.
18581865
downloadAndInstallPossibleCompilers ::
1859-
(HasGHCVariant env, HasBuildConfig env)
1860-
=> [CompilerBuild]
1861-
-> SetupInfo
1862-
-> WantedCompiler
1863-
-> VersionCheck
1864-
-> Maybe String
1865-
-> RIO env (Tool, CompilerBuild)
1866+
(HasGHCVariant env, HasBuildConfig env)
1867+
=> [CompilerBuild]
1868+
-> SetupInfo
1869+
-> WantedCompiler
1870+
-> VersionCheck
1871+
-> Maybe String
1872+
-> RIO env (Tool, CompilerBuild)
18661873
downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbindistURL =
18671874
go possibleCompilers Nothing
18681875
where
@@ -1911,9 +1918,7 @@ getGhcKey ghcBuild = do
19111918
<> T.pack (ghcVariantSuffix ghcVariant)
19121919
<> T.pack (compilerBuildSuffix ghcBuild)
19131920

1914-
getOSKey :: (MonadThrow m)
1915-
=> Platform
1916-
-> m Text
1921+
getOSKey :: (MonadThrow m) => Platform -> m Text
19171922
getOSKey platform =
19181923
case platform of
19191924
Platform I386 Cabal.Linux -> pure "linux32"
@@ -1963,8 +1968,8 @@ downloadOrUseLocal downloadLabel downloadInfo destination =
19631968
} = downloadInfo
19641969
when (isJust contentLength) $
19651970
prettyWarnS
1966-
"`content-length` is not checked and should not be specified when \
1967-
\`url` is a file path."
1971+
"`content-length` is not checked and should not be specified when \
1972+
\`url` is a file path."
19681973
when (isJust sha1) $
19691974
prettyWarnS
19701975
"`sha1` is not checked and should not be specified when `url` is a \
@@ -2012,14 +2017,15 @@ data ArchiveType
20122017
| TarGz
20132018
| SevenZ
20142019

2015-
installGHCPosix :: HasConfig env
2016-
=> GHCDownloadInfo
2017-
-> SetupInfo
2018-
-> Path Abs File
2019-
-> ArchiveType
2020-
-> Path Abs Dir
2021-
-> Path Abs Dir
2022-
-> RIO env ()
2020+
installGHCPosix ::
2021+
HasConfig env
2022+
=> GHCDownloadInfo
2023+
-> SetupInfo
2024+
-> Path Abs File
2025+
-> ArchiveType
2026+
-> Path Abs Dir
2027+
-> Path Abs Dir
2028+
-> RIO env ()
20232029
installGHCPosix downloadInfo _ archiveFile archiveType tempDir destDir = do
20242030
platform <- view platformL
20252031
menv0 <- view processContextL
@@ -2130,27 +2136,29 @@ instance Alternative (CheckDependency env) where
21302136
Left _ -> y
21312137
Right x' -> pure $ Right x'
21322138

2133-
installGHCWindows :: HasBuildConfig env
2134-
=> SetupInfo
2135-
-> Path Abs File
2136-
-> ArchiveType
2137-
-> Path Abs Dir
2138-
-> Path Abs Dir
2139-
-> RIO env ()
2139+
installGHCWindows ::
2140+
HasBuildConfig env
2141+
=> SetupInfo
2142+
-> Path Abs File
2143+
-> ArchiveType
2144+
-> Path Abs Dir
2145+
-> Path Abs Dir
2146+
-> RIO env ()
21402147
installGHCWindows si archiveFile archiveType _tempDir destDir = do
21412148
withUnpackedTarball7z "GHC" si archiveFile archiveType destDir
21422149
prettyInfoL
21432150
[ flow "GHC installed to"
21442151
, pretty destDir <> "."
21452152
]
21462153

2147-
installMsys2Windows :: HasBuildConfig env
2148-
=> SetupInfo
2149-
-> Path Abs File
2150-
-> ArchiveType
2151-
-> Path Abs Dir
2152-
-> Path Abs Dir
2153-
-> RIO env ()
2154+
installMsys2Windows ::
2155+
HasBuildConfig env
2156+
=> SetupInfo
2157+
-> Path Abs File
2158+
-> ArchiveType
2159+
-> Path Abs Dir
2160+
-> Path Abs Dir
2161+
-> RIO env ()
21542162
installMsys2Windows si archiveFile archiveType _tempDir destDir = do
21552163
exists <- liftIO $ D.doesDirectoryExist $ toFilePath destDir
21562164
when exists $
@@ -2159,10 +2167,9 @@ installMsys2Windows si archiveFile archiveType _tempDir destDir = do
21592167

21602168
withUnpackedTarball7z "MSYS2" si archiveFile archiveType destDir
21612169

2162-
21632170
-- I couldn't find this officially documented anywhere, but you need to run
2164-
-- the MSYS shell once in order to initialize some pacman stuff. Once that
2165-
-- run happens, you can just run commands as usual.
2171+
-- the MSYS shell once in order to initialize some pacman stuff. Once that run
2172+
-- happens, you can just run commands as usual.
21662173
menv0 <- view processContextL
21672174
newEnv0 <- modifyEnvVars menv0 $ Map.insert "MSYSTEM" "MSYS"
21682175
newEnv <- either throwM pure $ augmentPathMap
@@ -2179,15 +2186,16 @@ installMsys2Windows si archiveFile archiveType _tempDir destDir = do
21792186
-- Install git. We could install other useful things in the future too.
21802187
-- runCmd (Cmd (Just destDir) "pacman" menv ["-Sy", "--noconfirm", "git"]) Nothing
21812188

2182-
-- | Unpack a compressed tarball using 7zip. Expects a single directory in
2183-
-- the unpacked results, which is renamed to the destination directory.
2184-
withUnpackedTarball7z :: HasBuildConfig env
2185-
=> String -- ^ Name of tool, used in error messages
2186-
-> SetupInfo
2187-
-> Path Abs File -- ^ Path to archive file
2188-
-> ArchiveType
2189-
-> Path Abs Dir -- ^ Destination directory.
2190-
-> RIO env ()
2189+
-- | Unpack a compressed tarball using 7zip. Expects a single directory in the
2190+
-- unpacked results, which is renamed to the destination directory.
2191+
withUnpackedTarball7z ::
2192+
HasBuildConfig env
2193+
=> String -- ^ Name of tool, used in error messages
2194+
-> SetupInfo
2195+
-> Path Abs File -- ^ Path to archive file
2196+
-> ArchiveType
2197+
-> Path Abs Dir -- ^ Destination directory.
2198+
-> RIO env ()
21912199
withUnpackedTarball7z name si archiveFile archiveType destDir = do
21922200
suffix <-
21932201
case archiveType of
@@ -2225,9 +2233,10 @@ expectSingleUnpackedDir archiveFile destDir = do
22252233
-- | Download 7z as necessary, and get a function for unpacking things.
22262234
--
22272235
-- Returned function takes an unpack directory and archive.
2228-
setup7z :: (HasBuildConfig env, MonadIO m)
2229-
=> SetupInfo
2230-
-> RIO env (Path Abs Dir -> Path Abs File -> m ())
2236+
setup7z ::
2237+
(HasBuildConfig env, MonadIO m)
2238+
=> SetupInfo
2239+
-> RIO env (Path Abs Dir -> Path Abs File -> m ())
22312240
setup7z si = do
22322241
dir <- view $ configL.to configLocalPrograms
22332242
ensureDir dir
@@ -2278,11 +2287,12 @@ setup7z si = do
22782287
liftIO $ prettyThrowM (ProblemWhileDecompressing archive)
22792288
_ -> prettyThrowM SetupInfoMissingSevenz
22802289

2281-
chattyDownload :: HasTerm env
2282-
=> Text -- ^ label
2283-
-> DownloadInfo -- ^ URL, content-length, sha1, and sha256
2284-
-> Path Abs File -- ^ destination
2285-
-> RIO env ()
2290+
chattyDownload ::
2291+
HasTerm env
2292+
=> Text -- ^ label
2293+
-> DownloadInfo -- ^ URL, content-length, sha1, and sha256
2294+
-> Path Abs File -- ^ destination
2295+
-> RIO env ()
22862296
chattyDownload label downloadInfo path = do
22872297
let url = downloadInfoUrl downloadInfo
22882298
req <- parseUrlThrow $ T.unpack url
@@ -2324,8 +2334,10 @@ chattyDownload label downloadInfo path = do
23242334
mtotalSize = downloadInfoContentLength downloadInfo
23252335

23262336
-- | Perform a basic sanity check of GHC
2327-
sanityCheck :: (HasProcessContext env, HasLogFunc env)
2328-
=> Path Abs File -> RIO env ()
2337+
sanityCheck ::
2338+
(HasLogFunc env, HasProcessContext env)
2339+
=> Path Abs File
2340+
-> RIO env ()
23292341
sanityCheck ghc = withSystemTempDir "stack-sanity-check" $ \dir -> do
23302342
let fp = toFilePath $ dir </> relFileMainHs
23312343
liftIO $ S.writeFile fp $ T.encodeUtf8 $ T.pack $ unlines
@@ -2355,7 +2367,8 @@ removeHaskellEnvVars =
23552367
-- https://github.com/commercialhaskell/stack/issues/3444
23562368
Map.delete "GHCRTS"
23572369

2358-
-- | Get map of environment variables to set to change the GHC's encoding to UTF-8
2370+
-- | Get map of environment variables to set to change the GHC's encoding to
2371+
-- UTF-8.
23592372
getUtf8EnvVars ::
23602373
(HasPlatform env, HasProcessContext env, HasTerm env)
23612374
=> ActualCompiler
@@ -2505,7 +2518,7 @@ data HaskellStackOrg = HaskellStackOrg
25052518
deriving Show
25062519

25072520
downloadStackReleaseInfo ::
2508-
(HasPlatform env, HasLogFunc env)
2521+
(HasLogFunc env, HasPlatform env)
25092522
=> Maybe String -- GitHub org
25102523
-> Maybe String -- GitHub repo
25112524
-> Maybe String -- ^ optional version
@@ -2615,8 +2628,9 @@ downloadStackReleaseInfoGitHub morg mrepo mver = liftIO $ do
26152628
then pure $ SRIGitHub $ getResponseBody res
26162629
else prettyThrowIO $ StackReleaseInfoNotFound url
26172630

2618-
preferredPlatforms :: (MonadReader env m, HasPlatform env, MonadThrow m)
2619-
=> m [(Bool, String)]
2631+
preferredPlatforms ::
2632+
(MonadReader env m, HasPlatform env, MonadThrow m)
2633+
=> m [(Bool, String)]
26202634
preferredPlatforms = do
26212635
Platform arch' os' <- view platformL
26222636
(isWindows, os) <-

0 commit comments

Comments
 (0)