darcs-2.5.2: a distributed, interactive, smart revision control system

Darcs.Utils

Contents

- Tree filtering.
- Tree lookup.

Synopsis

- catchall :: IO a -> IO a -> IO a
- ortryrunning :: IO ExitCode -> IO ExitCode -> IO ExitCode
- nubsort :: Ord a => [a] -> [a]
- breakCommand :: String -> (String, [String])
- clarifyErrors :: IO a -> String -> IO a
- prettyException :: SomeException -> String
- prettyError :: IOError -> String
- putStrLnError :: String -> IO ()
- putDocLnError :: Doc -> IO ()
- withCurrentDirectory :: FilePathLike p => p -> IO a -> IO a
- withUMask :: String -> IO a -> IO a
- askUser :: String -> IO String
- stripCr :: String -> String
- showHexLen :: Integral a => Int -> a -> String
- addToErrorLoc :: IOException -> String -> IOException
- maybeGetEnv :: String -> IO (Maybe String)
- firstNotBlank :: [String] -> Maybe String
- firstJustM :: Monad m => [m (Maybe a)] -> m (Maybe a)
- firstJustIO :: [IO (Maybe a)] -> IO (Maybe a)
- getViewer :: IO String
- editFile :: FilePathLike p => p -> IO ExitCode
- runEditor :: FilePath -> IO ExitCode
- data PromptConfig = PromptConfig {
  - pPrompt :: String
  - pBasicCharacters :: [Char]
  - pAdvancedCharacters :: [Char]
  - pDefault :: Maybe Char
  - pHelp :: [Char]
  }
- promptYorn :: [Char] -> IO Char
- promptChar :: PromptConfig -> IO Char
- environmentHelpEditor :: ([String], [String])
- environmentHelpPager :: ([String], [String])
- formatPath :: String -> String
- isFileReallySymlink :: FilePath -> IO Bool
- doesDirectoryReallyExist :: FilePath -> IO Bool
- doesFileReallyExist :: FilePath -> IO Bool
- filterFilePaths :: [FilePath] -> AnchoredPath -> t -> Bool
- filterPaths :: [AnchoredPath] -> AnchoredPath -> t -> Bool
- treeHas :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool
- treeHasDir :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool
- treeHasFile :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool
- treeHasAnycase :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool

# Documentation

catchall :: IO a -> IO a -> IO a

ortryrunning :: IO ExitCode -> IO ExitCode -> IO ExitCode

Given two shell commands as arguments, execute the former. The latter is then executed if the former failed because the executable wasn't found (code 127), wasn't executable (code 126) or some other exception occurred. Other failures (such as the user holding ^C) do not cause the second command to be tried.

nubsort :: Ord a => [a] -> [a]

breakCommand :: String -> (String, [String])

clarifyErrors :: IO a -> String -> IO a

prettyException :: SomeException -> String

prettyError :: IOError -> String

putStrLnError :: String -> IO ()

putDocLnError :: Doc -> IO ()

withCurrentDirectory :: FilePathLike p => p -> IO a -> IO a

withUMask :: String -> IO a -> IO a

askUser

Arguments

:: String | The prompt to display
-> IO String | The string the user entered.

Ask the user for a line of input.

stripCr :: String -> String

showHexLen :: Integral a => Int -> a -> String

addToErrorLoc :: IOException -> String -> IOException

maybeGetEnv :: String -> IO (Maybe String)

firstNotBlank :: [String] -> Maybe String

Returns Just l where l is first non-blank string in input array; Nothing if no non-blank entries

firstJustM :: Monad m => [m (Maybe a)] -> m (Maybe a)

The firstJustM returns the first Just entry in a list of monadic operations. This is close to `listToMaybe `fmap` sequence`, but the sequence operator evaluates all monadic members of the list before passing it along (i.e. sequence is strict). The firstJustM is lazy in that list member monads are only evaluated up to the point where the first Just entry is obtained.

firstJustIO :: [IO (Maybe a)] -> IO (Maybe a)

The firstJustIO is a slight modification to firstJustM: the entries in the list must be IO monad operations and the firstJustIO will silently turn any monad call that throws an exception into Nothing, basically causing it to be ignored.

getViewer :: IO String

editFile :: FilePathLike p => p -> IO ExitCode

runEditor :: FilePath -> IO ExitCode

data PromptConfig

Constructors

PromptConfig |

Fields

pPrompt :: String
pBasicCharacters :: [Char]
pAdvancedCharacters :: [Char]

  only shown on help

pDefault :: Maybe Char
pHelp :: [Char]

promptYorn :: [Char] -> IO Char

promptChar :: PromptConfig -> IO Char

environmentHelpEditor :: ([String], [String])

environmentHelpPager :: ([String], [String])

formatPath :: String -> String

isFileReallySymlink :: FilePath -> IO Bool

doesDirectoryReallyExist :: FilePath -> IO Bool

doesFileReallyExist :: FilePath -> IO Bool

# Tree filtering.

filterFilePaths :: [FilePath] -> AnchoredPath -> t -> Bool

Same as `filterPath`, but for ordinary `FilePath`s (as opposed to AnchoredPath).

filterPaths :: [AnchoredPath] -> AnchoredPath -> t -> Bool

Construct a filter from a list of AnchoredPaths, that will accept any path that is either a parent or a child of any of the listed paths, and discard everything else.

# Tree lookup.

treeHas :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool

treeHasDir :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool

treeHasFile :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool

treeHasAnycase :: (MonadError e m, Functor m, Monad m) => Tree m -> FilePath -> m Bool