Path type.
This is used with the phantom 👻 types.
directoryPath : Path Directory
filePath : Path File
encapsulatedPath : Path Encapsulated
👻 Directory
👻 File
👻 Encapsulated
directory : List String -> Path Directory
Create a directory path.
directory [ "Audio", "Playlists" ]
file : List String -> Path File
Create a file path.
file [ "Document", "invoice.pdf" ]
root : Path Directory
Root directory.
fromPosix : String -> Path Encapsulated
Convert a POSIX formatted string to a path.
This will return a Encapsulated
path. To get a path of the type Path Directory
or Path File
, use the functions in the Webnative.Path.Encapsulated
module.
>>> import Webnative.Path.Encapsulated
>>> "foo/bar/"
..> |> fromPosix
..> |> Webnative.Path.Encapsulated.toDirectory
Just (directory [ "foo", "bar" ])
>>> "foo/bar"
..> |> fromPosix
..> |> Webnative.Path.Encapsulated.toFile
Just (file [ "foo", "bar" ])
toPosix : Path t -> String
Convert a path to the POSIX format.
>>> toPosix (directory [ "foo", "bar"])
"foo/bar/"
>>> toPosix (file [ "foo", "bar"])
"foo/bar"
encapsulate : Path t -> Path Encapsulated
Encapsulate a path.
kind : Path t -> Kind
Get the path kind.
>>> kind (directory [])
Directory
>>> kind (file [])
File
map : (List String -> List String) -> Path t -> Path t
Map.
unwrap : Path t -> List String
Get the path parts.
>>> unwrap (directory [ "foo", "bar" ])
[ "foo", "bar" ]
>>> unwrap (file [ "foo", "bar" ])
[ "foo", "bar" ]
encode : Path t -> Json.Encode.Value
Encode to JSON.
>>> import Json.Encode
>>> [ "foo" ]
..> |> directory
..> |> encode
..> |> Json.Encode.encode 0
"{\"directory\":[\"foo\"]}"
>>> [ "bar" ]
..> |> file
..> |> encode
..> |> Json.Encode.encode 0
"{\"file\":[\"bar\"]}"