String -> [String] -> String
Given a program p and arguments args, showCommandForUser p args returns a string suitable for pasting into sh (on POSIX OSs) or cmd.exe (on Windows).
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.
Alias to addExtension, for people who like that sort of thing.
Add an extension, even if there is already one there. E.g. addExtension "foo.txt" "bat" -> "foo.txt.bat".
> addExtension "file.txt" "bib" == "file.txt.bib"
> addExtension "file." ".bib" == "file..bib"
> addExtension "file" ".bib" == "file.bib"
> addExtension "/" "x" == "/.x"
> Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext"
> Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt"
Set the base name.
> replaceBaseName "file/test.txt" "bob" == "file/bob.txt"
> replaceBaseName "fred" "bill" == "bill"
> replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar"
> Valid x => replaceBaseName x (takeBaseName x) == x
Set the directory, keeping the filename the same.
> Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x
Set the extension of a file, overwriting one if already present.
> replaceExtension "file.txt" ".bob" == "file.bob"
> replaceExtension "file.txt" "bob" == "file.bob"
> replaceExtension "file" ".bob" == "file.bob"
> replaceExtension "file.txt" "" == "file"
> replaceExtension "file.fred.bob" "txt" == "file.fred.txt"
Set the filename.
> Valid x => replaceFileName x (takeFileName x) == x
Combine two paths, if the second path isAbsolute, then it returns the second.
> Valid x => combine (takeDirectory x) (takeFileName x) `equalFilePath` x
> Posix: combine "/" "test" == "/test"
> Posix: combine "home" "bob" == "home/bob"
> Windows: combine "home" "bob" == "home\\bob"
> Windows: combine "home" "/bob" == "/bob"
Join a drive and the rest of the path.
> uncurry joinDrive (splitDrive x) == x
> Windows: joinDrive "C:" "foo" == "C:foo"
> Windows: joinDrive "C:\\" "bar" == "C:\\bar"
> Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo"
> Windows: joinDrive "/:" "foo" == "/:\\foo"
Contract a filename, based on a relative path.
There is no corresponding makeAbsolute function, instead use System.Directory.canonicalizePath which has the same effect.
> Valid y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y </> makeRelative y x) x
> makeRelative x x == "."
> null y || equalFilePath (makeRelative x (x </> y)) y || null (takeFileName x)
> Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob"
> Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob"
> Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob"
> Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob"
> Windows: makeRelative "/Home" "/home/bob" == "bob"
> Posix: makeRelative "/Home" "/home/bob" == "/home/bob"
> Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar"
> Posix: makeRelative "/fred" "bob" == "bob"
> Posix: makeRelative "/file/test" "/file/test/fred" == "fred"
> Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/"
> Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c"
readProcess forks an external process, reads its standard output strictly, blocking until the process terminates, and returns the output string.
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.
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 path
* A list of separate command line arguments to the program
* A string to pass on the standard input to the program.
Replaces every occurance of the given regexp with the replacement string.
In the replacement string, "\1" refers to the first substring; "\2" to the second, etc; and "\0" to the entire match. "\\\\" will insert a literal backslash.
This does not advance if the regex matches an empty string. This misfeature is here to match the behavior of the the original Text.Regex API.
Get the value of a cookie from a string on the form "cookieName1=cookieValue1;...;cookieName2=cookieValue2". This is the format of the Cookie HTTP header.
getEnvDefault is a wrapper around getEnv programmer can specify a fallback if the variable is not found in the environment.
Append two lists, i.e.,
> [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
> [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
postRequestWithBody urlString typ body is convenience constructor for POST Requests. It constructs a request and sets the body as well as the Content-Type and Content-Length headers. The contents of the body are forced to calculate the value for the Content-Length header. If urlString isn't a syntactically valid URL, the function raises an error.
The deleteFirstsBy function takes a predicate and two lists and returns the first list with the first occurrence of each element of the second list removed.
Show more results