cabal-install-3.8.1.0: The command-line interface for Cabal and Hackage.
Safe HaskellNone
LanguageHaskell2010

Distribution.Client.Utils

Synopsis

Documentation

data MergeResult a b Source #

Constructors

OnlyInLeft a 
InBoth a b 
OnlyInRight b 

mergeBy :: forall a b. (a -> b -> Ordering) -> [a] -> [b] -> [MergeResult a b] Source #

Generic merging utility. For sorted input lists this is a full outer join.

duplicates :: Ord a => [a] -> [[a]] Source #

duplicatesBy :: forall a. (a -> a -> Ordering) -> [a] -> [[a]] Source #

readMaybe :: Read a => String -> Maybe a #

Parse a string using the Read instance. Succeeds if there is exactly one valid result.

>>> readMaybe "123" :: Maybe Int
Just 123
>>> readMaybe "hello" :: Maybe Int
Nothing

Since: base-4.6.0.0

inDir :: Maybe FilePath -> IO a -> IO a Source #

Executes the action in the specified directory.

Warning: This operation is NOT thread-safe, because current working directory is a process-global concept.

withEnv :: String -> String -> IO a -> IO a Source #

Executes the action with an environment variable set to some value.

Warning: This operation is NOT thread-safe, because current environment is a process-global concept.

withEnvOverrides :: [(String, Maybe FilePath)] -> IO a -> IO a Source #

Executes the action with a list of environment variables and corresponding overrides, where

  • Just v means "set the environment variable's value to v".
  • Nothing means "unset the environment variable".

Warning: This operation is NOT thread-safe, because current environment is a process-global concept.

logDirChange :: (String -> IO ()) -> Maybe FilePath -> IO a -> IO a Source #

Log directory change in make compatible syntax

withExtraPathEnv :: [FilePath] -> IO a -> IO a Source #

Executes the action, increasing the PATH environment in some way

Warning: This operation is NOT thread-safe, because the environment variables are a process-global concept.

determineNumJobs :: Flag (Maybe Int) -> Int Source #

Determine the number of jobs to use given the value of the '-j' flag.

removeExistingFile :: FilePath -> IO () Source #

Like removeFile, but does not throw an exception when the file does not exist.

withTempFileName :: FilePath -> String -> (FilePath -> IO a) -> IO a Source #

A variant of withTempFile that only gives us the file name, and while it will clean up the file afterwards, it's lenient if the file is moved/deleted.

makeAbsoluteToCwd :: FilePath -> IO FilePath Source #

Given a relative path, make it absolute relative to the current directory. Absolute paths are returned unmodified.

makeRelativeToCwd :: FilePath -> IO FilePath Source #

Given a path (relative or absolute), make it relative to the current directory, including using ../.. if necessary.

makeRelativeToDir :: FilePath -> FilePath -> IO FilePath Source #

Given a path (relative or absolute), make it relative to the given directory, including using ../.. if necessary.

makeRelativeCanonical :: FilePath -> FilePath -> FilePath Source #

Given a canonical absolute path and canonical absolute dir, make the path relative to the directory, including using ../.. if necessary. Returns the original absolute path if it is not on the same drive as the given dir.

filePathToByteString :: FilePath -> ByteString Source #

Convert a FilePath to a lazy ByteString. Each Char is encoded as a little-endian Word32.

tryCanonicalizePath :: FilePath -> IO FilePath Source #

Workaround for the inconsistent behaviour of canonicalizePath. Always throws an error if the path refers to a non-existent file.

canonicalizePathNoThrow :: FilePath -> IO FilePath Source #

A non-throwing wrapper for canonicalizePath. If canonicalizePath throws an exception, returns the path argument unmodified.

moreRecentFile :: FilePath -> FilePath -> IO Bool Source #

Like Distribution.Simple.Utils.moreRecentFile, but uses getModTime instead of getModificationTime for higher precision. We can't merge the two because Distribution.Client.Time uses MIN_VERSION macros.

existsAndIsMoreRecentThan :: FilePath -> FilePath -> IO Bool Source #

Like moreRecentFile, but also checks that the first file exists.

tryFindAddSourcePackageDesc :: Verbosity -> FilePath -> String -> IO FilePath Source #

Like tryFindPackageDesc, but with error specific to add-source deps.

tryFindPackageDesc :: Verbosity -> FilePath -> String -> IO FilePath Source #

Try to find a .cabal file, in directory depPath. Fails if one cannot be found, with err prefixing the error message. This function simply allows us to give a more descriptive error than that provided by findPackageDesc.

relaxEncodingErrors :: Handle -> IO () Source #

Sets the handler for encoding errors to one that transliterates invalid characters into one present in the encoding (i.e., '?'). This is opposed to the default behavior, which is to throw an exception on error. This function will ignore file handles that have a Unicode encoding set. It's a no-op for versions of base less than 4.4.

data ProgressPhase Source #

Phase of building a dependency. Represents current status of package dependency processing. See #4040 for details.

pvpize :: Bool -> Version -> VersionRange Source #

Given a version, return an API-compatible (according to PVP) version range.

If the boolean argument denotes whether to use a desugared representation (if True) or the new-style ^>=-form (if False).

Example: pvpize True (mkVersion [0,4,1]) produces the version range >= 0.4 && < 0.5 (which is the same as 0.4.*).

incVersion :: Int -> Version -> Version Source #

Increment the nth version component (counting from 0).

getCurrentYear :: IO Integer Source #

Returns the current calendar year.