Skip to content

Commit

Permalink
Change option name, type signature, documentation and reuse
Browse files Browse the repository at this point in the history
See Rahul's comment for more details:
typelead#3
  • Loading branch information
psibi committed Oct 29, 2016
1 parent 6f97887 commit ccbe5e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
12 changes: 4 additions & 8 deletions epm/Distribution/Client/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ performInstallations verbosity
}
reportingLevel = fromFlag (installBuildReports installFlags)
logsDir = fromFlag (globalLogsDir globalFlags)
etaPatchesDir = fromFlagOrDefault [] (installEtaPatchesDirectory installFlags)
etaPatchesDir = fromFlagOrDefault defaultPatchesDir (toFlag $ return $ fromFlag $ installEtaPatchesDirectory installFlags)

-- Should the build output be written to a log file instead of stdout?
useLogFile :: UseLogFile
Expand Down Expand Up @@ -1235,7 +1235,7 @@ installLocalPackage
:: Verbosity
-> JobLimit
-> PackageIdentifier -> PackageLocation FilePath -> FilePath
-> FilePath
-> IO FilePath -- ^ Patches directory option
-> (Maybe FilePath -> IO BuildResult)
-> IO BuildResult
installLocalPackage verbosity jobLimit pkgid location distPref patchDir installPkg =
Expand Down Expand Up @@ -1263,7 +1263,7 @@ installLocalTarballPackage
-> JobLimit
-> PackageIdentifier -> FilePath -> FilePath
-> (Maybe FilePath -> IO BuildResult)
-> FilePath
-> IO FilePath
-> IO BuildResult
installLocalTarballPackage verbosity jobLimit pkgid
tarballPath distPref installPkg patchDir = do
Expand All @@ -1277,7 +1277,7 @@ installLocalTarballPackage verbosity jobLimit pkgid
withJobLimit jobLimit $ do
info verbosity $ "Extracting " ++ tarballPath
++ " to " ++ tmpDirPath ++ "..."
patchedExtractTarGzFile verbosity tmpDirPath relUnpackedPath tarballPath (patchDir' patchDir)
patchedExtractTarGzFile verbosity tmpDirPath relUnpackedPath tarballPath patchDir
exists <- doesFileExist descFilePath
when (not exists) $
die $ "Package .cabal file not found: " ++ show descFilePath
Expand All @@ -1293,10 +1293,6 @@ installLocalTarballPackage verbosity jobLimit pkgid
--
-- TODO: 'cabal get happy && cd sandbox && cabal install ../happy' still
-- fails even with this workaround. We probably can live with that.
patchDir' pd = case pd of
[] -> defaultPatchesDir
_ -> return patchDir

maybeRenameDistDir :: FilePath -> IO ()
maybeRenameDistDir absUnpackedPath = do
let distDirPath = absUnpackedPath </> defaultDistPref
Expand Down
2 changes: 1 addition & 1 deletion epm/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ installOptions showOrParseArgs =
installSymlinkBinDir (\v flags -> flags { installSymlinkBinDir = v })
(reqArgFlag "DIR")

, option [] ["eta-patches-directory"]
, option [] ["patches-directory"]
"Specify explicit Eta patches directory"
installEtaPatchesDirectory (\v flags -> flags { installEtaPatchesDirectory = v })
(reqArgFlag "DIR")
Expand Down
11 changes: 1 addition & 10 deletions epm/Distribution/Client/Targets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import qualified Distribution.Client.Tar as Tar
import Distribution.Client.FetchUtils
import Distribution.Client.Utils ( tryFindPackageDesc )
import {-# SOURCE #-} Distribution.Client.Patch ( patchedTarPackageCabalFile )
import {-# SOURCE #-} Distribution.Client.Config (defaultCabalDir, defaultPatchesDir)

import Distribution.PackageDescription
( GenericPackageDescription, FlagName(..), FlagAssignment )
Expand Down Expand Up @@ -466,16 +467,6 @@ fetchPackageTarget verbosity target = case target of
-- This only affects targets given by location, named targets are unaffected.
--

-- We are not using the functions present in Client.Config and
-- instead defining it again to avoid cyclic import error.
defaultCabalDir :: IO FilePath
defaultCabalDir = getAppUserDataDirectory "epm"

defaultPatchesDir :: IO FilePath
defaultPatchesDir = do
dir <- defaultCabalDir
return $ dir </> "patches"

readPackageTarget :: Verbosity
-> PackageTarget (PackageLocation FilePath)
-> IO (PackageTarget SourcePackage)
Expand Down

0 comments on commit ccbe5e8

Please sign in to comment.