darcs-beta-2.7.98.3: a distributed, interactive, smart revision control system

Safe HaskellSafe-Infered

Darcs.Utils

Contents

Synopsis

Documentation

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

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]Source

showHexLen :: (Integral a, Show a) => Int -> a -> StringSource

Monads

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

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.

User prompts

askUserSource

Arguments

:: String

The prompt to display

-> IO String

The string the user entered.

Ask the user for a line of input.

askUserListItem :: String -> [String] -> IO StringSource

askUserListItem prompt xs enumerates xs on the screen, allowing the user to choose one of the items

data PromptConfig Source

Constructors

PromptConfig 

Fields

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

only shown on help

pDefault :: Maybe Char
 
pHelp :: [Char]
 

promptYorn :: [Char] -> IO BoolSource

Prompt the user for a yes or no

Text

editFile :: FilePathLike p => p -> IO (ExitCode, Bool)Source

editFile f lets the user edit a file which could but does not need to already exist. This function returns the exit code from the text editor and a flag indicating if the user made any changes.

Help

Errors and exceptions

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

Files and directories

isUTF8Locale :: String -> BoolSource

isUTF8 checks if an encoding is UTF-8 (or ascii, since it is a subset of UTF-8).

Tree filtering.

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

Same as filterPath, but for ordinary FilePaths (as opposed to AnchoredPath).

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

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 BoolSource