Path Module
Hosted interpreter permissions: Every function and value on this page requires no host permissions. Higher-order functions still enforce the requirements of their callbacks. These checks do not apply to CLI execution or compilation. See Host permissions.
All functions in this module are core builtins. They manipulate path strings without filesystem access. Rules are fixed on every platform: / is the only separator, comparison is case-sensitive and ordinal, and backslashes/drive letters are ordinary characters. The base for relative paths must be supplied explicitly. These functions do not inspect symlinks, check existence, or prove filesystem containment. Normalize inputs explicitly before glob matching if desired.
Path.normalize
None
Path.normalize : string -> string
Collapses repeated /, . segments, and resolvable .. segments. Absolute paths cannot ascend above /; unresolved leading parents in relative paths are preserved. Removes trailing separators. Empty relative results become ..
Path.normalize "a/./b/../c"
// "a/c"
Path.isAbsolute
None
Path.isAbsolute : string -> bool
Tests for a leading /. Drive letters and backslashes have no special meaning.
Path.isAbsolute "/a"
// true
Path.combine
None
Path.combine : string -> string -> string
Joins and normalizes two paths. An absolute right argument replaces the left argument.
Path.combine "a/b" "../c"
// "a/c"
Path.fileName
None
Path.fileName : string -> string
Returns the last segment after trimming trailing / characters. The root path produces the empty string.
Path.fileName "a/b.txt"
// "b.txt"
Path.extension
None
Path.extension : string -> string option
Returns the final extension including its dot, or None for a dotfile, absent extension, or trailing dot.
Path.extension "a/b.txt"
// Some ".txt"
Path.fileNameWithoutExtension
None
Path.fileNameWithoutExtension : string -> string
Returns the last segment without its final extension. A leading dot alone does not introduce an extension.
Path.fileNameWithoutExtension "a/b.txt"
// "b"
Path.parent
None
Path.parent : string -> string option
Returns the parent of a normalized path. A single relative filename has parent .; / and . have no parent.
Path.parent "a/b.txt"
// Some "a"
Path.relative
None
Path.relative : string -> string -> string option
Computes a lexical path from the supplied base directory to the target. Returns None for mixed absolute/relative paths or unresolved parents remaining in the base after removing the common prefix. Equal paths return Some ".".
Path.relative "/a/b" "/a/c/file"
// Some "../c/file"