Ord a => [a] -> [a] -base
O(n) The transpose function transposes the rows and columns of its Text argument. Note that this function uses pack, unpack, and the list version of transpose, and is thus not very efficient.
Returns no shrinking alternatives.
Case normalization; cf. RFC3986 section 6.2.2.1 NOTE: authority case normalization is not performed
Encoding normalization; cf. RFC3986 section 6.2.2.2
Path segment normalization; cf. RFC3986 section 6.2.2.4
Processing Strings into Html friendly things.
Simplifies the input string by interpreting \r and \b characters specially so that the result string has the same final (or terminal, pun intended) appearance as would the input string when written to a terminal that overwrites character positions following carriage returns and backspaces.
Turns all instances of escaped characters in the string back into literal characters.
Converts a single value from the application/x-www-form-urlencoded encoding.
Converts a single value to the application/x-www-form-urlencoded encoding.
Add a trailing file path separator if one is not already present.
> hasTrailingPathSeparator (addTrailingPathSeparator x)
> hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x
> Posix: addTrailingPathSeparator "test/rest" == "test/rest/"
Delete the drive, if it exists.
> dropDrive x == snd (splitDrive x)
Remove last extension, and the "." preceding it.
> dropExtension x == fst (splitExtension x)
Drop all extensions
> not $ hasExtension (dropExtensions x)
Drop the filename.
> dropFileName x == fst (splitFileName x)
Remove any trailing path separators
> dropTrailingPathSeparator "file/test/" == "file/test"
> Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x
> Posix: dropTrailingPathSeparator "/" == "/"
> Windows: dropTrailingPathSeparator "\\" == "\\"
Take a FilePath and make it valid; does not change already valid FilePaths.
> isValid (makeValid x)
> isValid x ==> makeValid x == x
> makeValid "" == "_"
> Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test"
> Windows: makeValid "test*" == "test_"
> Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_"
> Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt"
> Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt"
> Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file"
Normalise a file
* // outside of the drive can be made blank
* / -> pathSeparator
* ./ -> ""
> Posix: normalise "/file/\\test////" == "/file/\\test/"
> Posix: normalise "/file/./test" == "/file/test"
> Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/"
> Posix: normalise "../bob/fred/" == "../bob/fred/"
> Posix: normalise "./bob/fred/" == "bob/fred/"
> Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
> Windows: normalise "c:\\" == "C:\\"
> Windows: normalise "\\\\server\\test" == "\\\\server\\test"
> Windows: normalise "c:/file" == "C:\\file"
> normalise "." == "."
> Posix: normalise "./" == "./"
> Posix: normalise "./." == "./"
> Posix: normalise "/" == "/"
> Posix: normalise "bob/fred/." == "bob/fred/"
Get the directory name, move up one level.
> takeDirectory x `isPrefixOf` x || takeDirectory x == "."
> takeDirectory "foo" == "."
> takeDirectory "/foo/bar/baz" == "/foo/bar"
> takeDirectory "/foo/bar/baz/" == "/foo/bar/baz"
> takeDirectory "foo/bar/baz" == "foo/bar"
> Windows: takeDirectory "foo\\bar" == "foo"
> Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar"
> Windows: takeDirectory "C:\\" == "C:\\"
Get the drive from a filepath.
> takeDrive x == fst (splitDrive x)
Get the file name.
> takeFileName "test/" == ""
> takeFileName x `isSuffixOf` x
> takeFileName x == snd (splitFileName x)
> Valid x => takeFileName (replaceFileName x "fred") == "fred"
> Valid x => takeFileName (x </> "fred") == "fred"
> Valid x => isRelative (takeFileName x)
Get the base name, without an extension or path.
> takeBaseName "file/test.txt" == "test"
> takeBaseName "dave.ext" == "dave"
> takeBaseName "" == ""
> takeBaseName "test" == "test"
> takeBaseName (addTrailingPathSeparator x) == ""
> takeBaseName "file/file.tar.gz" == "file.tar"
Get the extension of a file, returns "" for no extension, .ext otherwise.
> takeExtension x == snd (splitExtension x)
> Valid x => takeExtension (addExtension x "ext") == ".ext"
> Valid x => takeExtension (replaceExtension x "ext") == ".ext"
Get all extensions
> takeExtensions "file.tar.gz" == ".tar.gz"
Can be used to make a string valid for use in a URI.
Outputs indented XHTML. Because space matters in HTML, the output is quite messy.
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"
Shrink a fraction.
Shrink an integral number.
Replaces all instances of a value in a list by another value.
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
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).
Show more results