HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulecabal-install-3.12.1.0Haskell2010

Distribution.Client.Utils

  • 2 types
  • 37 values
valuemergeBy :: (a -> b -> Ordering) -> [a] -> [b] -> [MergeResult a b]
#

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

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

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

Example1 expression
readMaybe "123" :: Maybe IntJust 123
Example1 expression
readMaybe "hello" :: Maybe IntNothing
valueinDir :: Maybe FilePath -> IO a -> IO a
#

Executes the action in the specified directory.

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

valuewithEnv :: String -> String -> IO a -> IO a
#

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.

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

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.

valuewithExtraPathEnv :: [FilePath] -> IO a -> IO a
#

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.

valuewithTempFileName :: FilePath -> String -> (FilePath -> IO a) -> IO a
#

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.

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.

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.

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.

valuerelaxEncodingErrors :: Handle -> IO ()
#

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.

valuepvpize :: Bool -> Version -> VersionRange
#

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.*).

valuehasElem :: Ord a => [a] -> a -> Bool
#

hasElem xs x = elem x xs except that xs is turned into a Set first. Use underapplied to speed up subsequent lookups, e.g. filter (hasElem xs) ys. Only amortized when used several times!

Time complexity O((n+m) \log(n)) for m lookups in a list of length n. (Compare this to elem's O(nm).)

This is Agda.Utils.List.hasElem.