HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

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.

Contents
  1. Basic properties
  2. Basic operations
  3. Extensions
Synopsis
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

Basic properties

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

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

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

Orphan instances

2 instances