Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data MergeResult a b
- = OnlyInLeft a
- | InBoth a b
- | OnlyInRight b
- mergeBy :: forall a b. (a -> b -> Ordering) -> [a] -> [b] -> [MergeResult a b]
- duplicates :: Ord a => [a] -> [[a]]
- duplicatesBy :: forall a. (a -> a -> Ordering) -> [a] -> [[a]]
- readMaybe :: Read a => String -> Maybe a
- inDir :: Maybe FilePath -> IO a -> IO a
- withEnv :: String -> String -> IO a -> IO a
- withEnvOverrides :: [(String, Maybe FilePath)] -> IO a -> IO a
- logDirChange :: (String -> IO ()) -> Maybe FilePath -> IO a -> IO a
- withExtraPathEnv :: [FilePath] -> IO a -> IO a
- determineNumJobs :: Flag (Maybe Int) -> Int
- numberOfProcessors :: Int
- removeExistingFile :: FilePath -> IO ()
- withTempFileName :: FilePath -> String -> (FilePath -> IO a) -> IO a
- makeAbsoluteToCwd :: FilePath -> IO FilePath
- makeRelativeToCwd :: FilePath -> IO FilePath
- makeRelativeToDir :: FilePath -> FilePath -> IO FilePath
- makeRelativeCanonical :: FilePath -> FilePath -> FilePath
- filePathToByteString :: FilePath -> ByteString
- byteStringToFilePath :: ByteString -> FilePath
- tryCanonicalizePath :: FilePath -> IO FilePath
- canonicalizePathNoThrow :: FilePath -> IO FilePath
- moreRecentFile :: FilePath -> FilePath -> IO Bool
- existsAndIsMoreRecentThan :: FilePath -> FilePath -> IO Bool
- tryFindAddSourcePackageDesc :: Verbosity -> FilePath -> String -> IO FilePath
- tryFindPackageDesc :: Verbosity -> FilePath -> String -> IO FilePath
- findOpenProgramLocation :: Platform -> IO (Either String FilePath)
- relaxEncodingErrors :: Handle -> IO ()
- data ProgressPhase
- progressMessage :: Verbosity -> ProgressPhase -> String -> IO ()
- pvpize :: Bool -> Version -> VersionRange
- incVersion :: Int -> Version -> Version
- getCurrentYear :: IO Integer
- listFilesRecursive :: FilePath -> IO [FilePath]
- listFilesInside :: (FilePath -> IO Bool) -> FilePath -> IO [FilePath]
- safeRead :: Read a => String -> Maybe a
- hasElem :: Ord a => [a] -> a -> Bool
Documentation
data MergeResult a b Source #
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.
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.
byteStringToFilePath :: ByteString -> FilePath Source #
Reverse operation to filePathToByteString
.
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.
progressMessage :: Verbosity -> ProgressPhase -> String -> IO () Source #
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.
listFilesRecursive :: FilePath -> IO [FilePath] Source #
From System.Directory.Extra https://hackage.haskell.org/package/extra-1.7.9
listFilesInside :: (FilePath -> IO Bool) -> FilePath -> IO [FilePath] Source #
From System.Directory.Extra https://hackage.haskell.org/package/extra-1.7.9
hasElem :: Ord a => [a] -> a -> Bool Source #
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.