Cross-platform file path utilities for BackendTask.File and Pages.Script.
The representation is opaque so we can evolve path behavior over time without exposing implementation details.
Build a path from a string. Accepts both / and \\ separators.
This normalizes the path to a stable representation:
\\ to /. segments.. segments when possibleIt accepts both relative and absolute paths.
Build a relative path from segments.
FilePath.relative [ "src", "Main.elm" ]
|> FilePath.toString
--> "src/Main.elm"Build an absolute path from segments.
FilePath.absolute [ "usr", "bin" ]
|> FilePath.toString
--> "/usr/bin"Append a path to a base path.
If nextPath has a root marker (absolute path, UNC path, or drive prefix), it replaces
the base path.
Filename without extension.
Path to targetPath relative to basePath.
Returns Nothing when roots differ.
fromString "/foo/bar/qux"
|> relativeTo (fromString "/foo")
--> Just (fromString "bar/qux")Resolve a file path to an absolute path using the OS-aware path.resolve from Node.js.
Relative paths are resolved against the current working directory.
import BackendTask exposing (BackendTask)
import FatalError exposing (FatalError)
import FilePath
resolveExample : BackendTask FatalError FilePath
resolveExample =
FilePath.fromString "src/Main.elm"
|> FilePath.resolve
Opaque file path type.