ghc-mod-5.7.0.0: Happy Haskell Programming

Safe Haskell | None
Language | Haskell2010

Language.Haskell.GhcMod.Utils

Synopsis

- dropWhileEnd :: (a -> Bool) -> [a] -> [a]
- withDirectory_ :: (MonadIO m, ExceptionMonad m) => FilePath -> m a -> m a
- uniqTempDirName :: FilePath -> FilePath
- newTempDir :: FilePath -> IO FilePath
- whenM :: Monad m => m Bool -> m () -> m ()
- ghcModExecutable :: IO FilePath
- findLibexecExe :: String -> IO FilePath
- libexecNotExitsError :: String -> FilePath -> String
- tryFindGhcModTreeLibexecDir :: IO (Maybe FilePath)
- tryFindGhcModTreeDataDir :: IO (Maybe FilePath)
- readLibExecProcess' :: (MonadIO m, ExceptionMonad m) => String -> [String] -> m String
- getExecutablePath' :: IO FilePath
- canonFilePath :: FilePath -> IO FilePath
- withMappedFile :: (IOish m, GmState m, GmEnv m) => forall a. FilePath -> (FilePath -> m a) -> m a
- getCanonicalFileNameSafe :: (IOish m, GmEnv m) => FilePath -> m FilePath
- mkRevRedirMapFunc :: (Functor m, GmState m, GmEnv m) => m (FilePath -> FilePath)
- findFilesWith' :: (FilePath -> IO Bool) -> [FilePath] -> String -> IO [FilePath]
- makeAbsolute' :: FilePath -> IO FilePath
- data TimedFile = TimedFile {
  - tfPath :: FilePath
  - tfTime :: ModTime
  }
- timeFile :: FilePath -> IO TimedFile
- mightExist :: FilePath -> IO (Maybe FilePath)
- timeMaybe :: FilePath -> IO (Maybe TimedFile)
- readProcess :: FilePath -> [String] -> String -> IO String

# Documentation

dropWhileEnd :: (a -> Bool) -> [a] -> [a] #

withDirectory_ :: (MonadIO m, ExceptionMonad m) => FilePath -> m a -> m a #

uniqTempDirName :: FilePath -> FilePath #

newTempDir :: FilePath -> IO FilePath #

whenM :: Monad m => m Bool -> m () -> m () #

ghcModExecutable :: IO FilePath #

Returns the path to the currently running ghc-mod executable. With ghc<7.6 this is a guess but >=7.6 uses `getExecutablePath`.

findLibexecExe :: String -> IO FilePath #

libexecNotExitsError :: String -> FilePath -> String #

tryFindGhcModTreeLibexecDir :: IO (Maybe FilePath) #

tryFindGhcModTreeDataDir :: IO (Maybe FilePath) #

readLibExecProcess' :: (MonadIO m, ExceptionMonad m) => String -> [String] -> m String #

getExecutablePath' :: IO FilePath #

canonFilePath :: FilePath -> IO FilePath #

withMappedFile :: (IOish m, GmState m, GmEnv m) => forall a. FilePath -> (FilePath -> m a) -> m a #

getCanonicalFileNameSafe :: (IOish m, GmEnv m) => FilePath -> m FilePath #

mkRevRedirMapFunc :: (Functor m, GmState m, GmEnv m) => m (FilePath -> FilePath) #

findFilesWith' :: (FilePath -> IO Bool) -> [FilePath] -> String -> IO [FilePath] #

makeAbsolute' :: FilePath -> IO FilePath #

Make a path absolute by prepending the current directory (if it isn't already absolute) and applying `normalise` to the result.

If the path is already absolute, the operation never fails. Otherwise, the operation may fail with the same exceptions as `getCurrentDirectory`.

data TimedFile #

Constructors

TimedFile |
Fields tfPath :: FilePath tfTime :: ModTime

Instances

Eq TimedFile # |
Methods (==) :: TimedFile -> TimedFile -> Bool # (/=) :: TimedFile -> TimedFile -> Bool #
Ord TimedFile # |
Methods compare :: TimedFile -> TimedFile -> Ordering # (<) :: TimedFile -> TimedFile -> Bool # (<=) :: TimedFile -> TimedFile -> Bool # (>) :: TimedFile -> TimedFile -> Bool # (>=) :: TimedFile -> TimedFile -> Bool # max :: TimedFile -> TimedFile -> TimedFile # min :: TimedFile -> TimedFile -> TimedFile #

timeFile :: FilePath -> IO TimedFile #

mightExist :: FilePath -> IO (Maybe FilePath) #

timeMaybe :: FilePath -> IO (Maybe TimedFile) #

readProcess #

Arguments

:: FilePath | Filename of the executable (see `RawCommand` for details)
-> [String] | any arguments
-> String | standard input
-> IO String | stdout

`readProcess` forks an external process, reads its standard output strictly, blocking until the process terminates, and returns the output string. The external process inherits the standard error.

If an asynchronous exception is thrown to the thread executing `readProcess`, the forked process will be terminated and `readProcess` will wait (block) until the process has been terminated.

Output is returned strictly, so this is not suitable for interactive applications.

This function throws an `IOError` if the process `ExitCode` is anything other than `ExitSuccess`. If instead you want to get the `ExitCode` then use `readProcessWithExitCode`.

Users of this function should compile with `-threaded` if they want other Haskell threads to keep running while waiting on the result of readProcess.

     > readProcess "date" [] []
     "Thu Feb  7 10:03:39 PST 2008\n"

The arguments are:

- The command to run, which must be in the $PATH, or an absolute or relative path
- A list of separate command line arguments to the program
- A string to pass on standard input to the forked process.