66{-# LANGUAGE RecordWildCards #-}
77{-# LANGUAGE TemplateHaskell #-}
88{-# LANGUAGE LambdaCase #-}
9+ {-# LANGUAGE TypeFamilies #-}
910-- | Perform a build
1011module Stack.Build.Execute
1112 ( printPlan
@@ -25,11 +26,11 @@ import Control.Concurrent.STM
2526import Control.Exception.Enclosed (catchIO )
2627import Control.Exception.Lifted
2728import Control.Monad (liftM , when , unless , void )
28- import Control.Monad.Catch (MonadCatch , MonadMask )
29+ import Control.Monad.Catch (MonadCatch )
2930import Control.Monad.Extra (anyM , (&&^) )
3031import Control.Monad.IO.Class
3132import Control.Monad.Logger
32- import Control.Monad.Reader (MonadReader , asks )
33+ import Control.Monad.Reader (asks )
3334import Control.Monad.Trans.Control (liftBaseWith )
3435import Control.Monad.Trans.Resource
3536import qualified Crypto.Hash.SHA256 as SHA256
@@ -68,7 +69,6 @@ import Distribution.System (OS (Windows),
6869 Platform (Platform ))
6970import qualified Distribution.Text as C
7071import Language.Haskell.TH as TH (location )
71- import Network.HTTP.Client.Conduit (HasHttpManager )
7272import Path
7373import Path.Extra (toFilePathNoTrailingSep , rejectMissingFile )
7474import Path.IO hiding (findExecutable , makeAbsolute )
@@ -110,10 +110,8 @@ import System.Process.Run
110110import System.Process.Internals (createProcess_ )
111111#endif
112112
113- type M env m = (MonadIO m ,MonadReader env m ,HasHttpManager env ,HasBuildConfig env ,MonadLogger m ,MonadBaseControl IO m ,MonadMask m ,HasLogLevel env ,HasEnvConfig env ,HasTerminal env , HasConfig env )
114-
115113-- | Fetch the packages necessary for a build, for example in combination with a dry run.
116- preFetch :: M env m => Plan -> m ()
114+ preFetch :: ( StackM env m , HasEnvConfig env ) => Plan -> m ()
117115preFetch plan
118116 | Set. null idents = $ logDebug " Nothing to fetch"
119117 | otherwise = do
@@ -133,7 +131,7 @@ preFetch plan
133131 (packageVersion package)
134132
135133-- | Print a description of build plan for human consumption.
136- printPlan :: M env m
134+ printPlan :: ( StackM env m , HasEnvConfig env )
137135 => Plan
138136 -> m ()
139137printPlan plan = do
@@ -261,7 +259,7 @@ simpleSetupHash =
261259 encodeUtf8 (T. pack (unwords buildSetupArgs)) <> setupGhciShimCode <> simpleSetupCode
262260
263261-- | Get a compiled Setup exe
264- getSetupExe :: M env m
262+ getSetupExe :: ( StackM env m , HasEnvConfig env )
265263 => Path Abs File -- ^ Setup.hs input file
266264 -> Path Abs File -- ^ SetupShim.hs input file
267265 -> Path Abs Dir -- ^ temporary directory
@@ -322,7 +320,7 @@ getSetupExe setupHs setupShimHs tmpdir = do
322320 return $ Just exePath
323321
324322-- | Execute a callback that takes an 'ExecuteEnv'.
325- withExecuteEnv :: M env m
323+ withExecuteEnv :: ( StackM env m , HasEnvConfig env )
326324 => EnvOverride
327325 -> BuildOpts
328326 -> BuildOptsCLI
@@ -440,7 +438,7 @@ withExecuteEnv menv bopts boptsCli baseConfigOpts locals globalPackages snapshot
440438 $ logInfo $ T. pack $ " \n -- End of log file: " ++ toFilePath filepath ++ " \n "
441439
442440-- | Perform the actual plan
443- executePlan :: M env m
441+ executePlan :: ( StackM env m , HasEnvConfig env )
444442 => EnvOverride
445443 -> BuildOptsCLI
446444 -> BaseConfigOpts
@@ -575,7 +573,7 @@ windowsRenameCopy src dest = do
575573 old = dest ++ " .old"
576574
577575-- | Perform the actual plan (internal)
578- executePlan' :: M env m
576+ executePlan' :: ( StackM env m , HasEnvConfig env )
579577 => InstalledMap
580578 -> Map PackageName SimpleTarget
581579 -> Plan
@@ -671,7 +669,7 @@ executePlan' installedMap0 targets plan ee@ExecuteEnv {..} = do
671669 $ Map. elems
672670 $ planUnregisterLocal plan
673671
674- toActions :: M env m
672+ toActions :: ( StackM env m , HasEnvConfig env )
675673 => InstalledMap
676674 -> (m () -> IO () )
677675 -> ExecuteEnv
@@ -725,7 +723,7 @@ toActions installedMap runInBase ee (mbuild, mfinal) =
725723 beopts = boptsBenchmarkOpts bopts
726724
727725-- | Generate the ConfigCache
728- getConfigCache :: M env m
726+ getConfigCache :: ( StackM env m , HasEnvConfig env )
729727 => ExecuteEnv -> Task -> InstalledMap -> Bool -> Bool
730728 -> m (Map PackageIdentifier GhcPkgId , ConfigCache )
731729getConfigCache ExecuteEnv {.. } Task {.. } installedMap enableTest enableBench = do
@@ -770,7 +768,7 @@ getConfigCache ExecuteEnv {..} Task {..} installedMap enableTest enableBench = d
770768 return (allDepsMap, cache)
771769
772770-- | Ensure that the configuration for the package matches what is given
773- ensureConfig :: M env m
771+ ensureConfig :: ( StackM env m , HasEnvConfig env )
774772 => ConfigCache -- ^ newConfigCache
775773 -> Path Abs Dir -- ^ package directory
776774 -> ExecuteEnv
@@ -831,7 +829,7 @@ announceTask task x = $logInfo $ T.concat
831829 , x
832830 ]
833831
834- withSingleContext :: M env m
832+ withSingleContext :: ( StackM env m , HasEnvConfig env )
835833 => (m () -> IO () )
836834 -> ActionContext
837835 -> ExecuteEnv
@@ -1047,7 +1045,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
10471045 return (outputFile, setupArgs)
10481046 runExe exeName $ (if boptsCabalVerbose eeBuildOpts then (" --verbose" : ) else id ) fullArgs
10491047
1050- singleBuild :: M env m
1048+ singleBuild :: ( StackM env m , HasEnvConfig env )
10511049 => (m () -> IO () )
10521050 -> ActionContext
10531051 -> ExecuteEnv
@@ -1315,7 +1313,7 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
13151313 _ -> error " singleBuild: invariant violated: multiple results when describing installed package"
13161314
13171315-- | Check if any unlisted files have been found, and add them to the build cache.
1318- checkForUnlistedFiles :: M env m => TaskType -> ModTime -> Path Abs Dir -> m [PackageWarning ]
1316+ checkForUnlistedFiles :: ( StackM env m , HasEnvConfig env ) => TaskType -> ModTime -> Path Abs Dir -> m [PackageWarning ]
13191317checkForUnlistedFiles (TTLocal lp) preBuildTime pkgDir = do
13201318 (addBuildCache,warnings) <-
13211319 addUnlistedToBuildCache
@@ -1338,7 +1336,7 @@ depsPresent installedMap deps = all
13381336 Nothing -> False )
13391337 (Map. toList deps)
13401338
1341- singleTest :: M env m
1339+ singleTest :: ( StackM env m , HasEnvConfig env )
13421340 => (m () -> IO () )
13431341 -> TestOpts
13441342 -> [Text ]
@@ -1481,7 +1479,7 @@ singleTest runInBase topts testsToRun ac ee task installedMap = do
14811479 (fmap fst mlogFile)
14821480 bs
14831481
1484- singleBench :: M env m
1482+ singleBench :: ( StackM env m , HasEnvConfig env )
14851483 => (m () -> IO () )
14861484 -> BenchmarkOpts
14871485 -> [Text ]
@@ -1573,7 +1571,7 @@ getSetupHs dir = do
15731571-- Do not pass `-hpcdir` as GHC option if the coverage is not enabled.
15741572-- This helps running stack-compiled programs with dynamic interpreters like `hint`.
15751573-- Cfr: https://github.com/commercialhaskell/stack/issues/997
1576- extraBuildOptions :: M env m => WhichCompiler -> BuildOpts -> m [String ]
1574+ extraBuildOptions :: ( StackM env m , HasEnvConfig env ) => WhichCompiler -> BuildOpts -> m [String ]
15771575extraBuildOptions wc bopts = do
15781576 let ddumpOpts = " -ddump-hi -ddump-to-file"
15791577 optsFlag = compilerOptionsCabalFlag wc
0 commit comments