HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesystem-filepath-0.4.14.1Haskell2010

Filesystem.Path

High‐level, byte‐based file and directory path manipulations. You probably want to import Filesystem.Path.CurrentOS instead, since it handles detecting which rules to use in the current compilation.

  • 1 type
  • 29 values
datadata FilePath
#
Instances8Eq, Data, Ord, Show, IsString, Semigroup, …
  • Eq FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.Internal
  • Data FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.Internal
  • Ord FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.Internal
  • Show FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.CurrentOS · orphan
  • IsString FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.CurrentOS · orphan
  • Semigroup FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path · orphan
  • Monoid FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path · orphan
  • NFData FilePathDefined in system-filepath-0.4.14.1 · Filesystem.Path.Internal
valueempty :: FilePath
#

A file path with no root, directory, or filename

Basic properties

9 declarations
valuedirname :: FilePath -> FilePath
#

Retrieve a FilePath’s directory name. This is only the file name of the directory, not its full path.

dirname "foo/bar/baz.txt" == "bar"
dirname "/" == ""

Since: 0.4.1

Basic operations

7 declarations

Remove a prefix from a path.

stripPrefix "/foo/" "/foo/bar/baz.txt" == Just "bar/baz.txt"
stripPrefix "/foo/" "/bar/baz.txt" == Nothing

This function operates on logical prefixes, rather than by counting characters. The prefix "/foo/bar/baz" is interpreted the path ("/foo/bar/", "baz"), and will be stripped accordingly:

stripPrefix "/foo/bar/baz" "/foo/bar/baz/qux" == Nothing
stripPrefix "/foo/bar/baz" "/foo/bar/baz.txt" == Just ".txt"

Since: 0.4.1

valuecollapse :: FilePath -> FilePath
#

Remove intermediate "." and ".." directories from a path.

collapse "/foo/./bar" == "/foo/bar"
collapse "/foo/bar/../baz" == "/foo/baz"
collapse "/foo/../../bar" == "/bar"
collapse "./foo/bar" == "./foo/baz"

Note that if any of the elements are symbolic links, collapse may change which file the path resolves to.

Since: 0.2

Extensions

12 declarations

Orphan instances

2 instances