:: FilePath -> String -package:BNFC -package:basic-prelude -is:exact -package:shake
Get the extension of a file, returns
"" for no extension,
.ext otherwise.
takeExtension "/directory/path.ext" == ".ext"
takeExtension x == snd (splitExtension x)
Valid x => takeExtension (addExtension x "ext") == ".ext"
Valid x => takeExtension (replaceExtension x "ext") == ".ext"
Get all extensions.
takeExtensions "/directory/path.ext" == ".ext"
takeExtensions "file.tar.gz" == ".tar.gz"
Get the base name, without an extension or path.
takeBaseName "/directory/file.ext" == "file"
takeBaseName "file/test.txt" == "test"
takeBaseName "dave.ext" == "dave"
takeBaseName "" == ""
takeBaseName "test" == "test"
takeBaseName (addTrailingPathSeparator x) == ""
takeBaseName "file/file.tar.gz" == "file.tar"
Attempt to convert a
FilePath to a string suitable for use with
functions in
System.IO. The contents of this string are
platform‐dependent, and are not guaranteed to be human‐readable. For
converting
FilePaths to a human‐readable format, use
toText.
Since: 0.3.1
Derive module name from specified path.
Deprecated: Use id instead
Retrieve a
FilePath's basename component
The golden test context for adding context to a golden test assertion:
goldenTestCompare = \actual expected ->
if actual == expected
then Nothing
else Just $ Context (stringsNotEqualButShouldHaveBeenEqual actual expected) (goldenContext fp)
Convert a filepath to an URL starting from the site root
Example:
toUrl "foo/bar.html"
Result:
"/foo/bar.html"
This also sanitizes the URL, e.g. converting spaces into '%20'
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"
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"
Convert a
FilePath to a platform‐specific format, suitable for
use with external OS functions.
Note: The type
platformTextFormat can change depending upon
the underlying compilation platform. Consider using
toText or
encodeString instead. See
Rules for more information.
Since: 0.3
base Prelude Text.Show GHC.Show,
hedgehog Hedgehog.Internal.Prelude,
ghc GHC.Prelude.Basic,
base-compat Prelude.Compat,
protolude Protolude.Base,
haskell-gi-base Data.GI.Base.ShortPrelude,
rio RIO.Prelude,
base-prelude BasePrelude,
classy-prelude ClassyPrelude,
numeric-prelude NumericPrelude NumericPrelude.Base,
Cabal-syntax Distribution.Compat.Prelude,
github GitHub.Internal.Prelude,
numhask NumHask.Prelude,
basement Basement.Compat.Base A specialised variant of
showsPrec, using precedence context
zero, and returning an ordinary
String.
Convert a generic value into a pretty
Value, if possible.
The type passed in must have a Show instance which produces a
valid Haskell expression. Returns an empty String if this is
not the case. This is not TH-specific, but useful in general.
show, but with an extra underscore so that its promoted
counterpart (
Show_) will not clash with the
Show
class.
Use the Show class to create a String.
Note that this is not efficient, since an intermediate [Char] is going
to be created before turning into a real String.