Designing a Paths Julep

Good point. I think

# equivalent to joinpath
/(::Path, ::Path) -> Path
/(::Path, ::String) -> Path

## equivalent to string concat (like file extensions)?
# [deleted] *(::Path, ::String) -> Path

# invalid
*(::Path, ::Path) -> error
*(::String, Path) -> error
/(::String, ::Path) -> error
/(::String, ::String) -> error

I think making * completely invalid for use on Path would also be a good option, to avoid ambiguity here [edit: yeah probably just do this].

Also, if relative paths is made a different type from an absolute path (which semantically seems good), you could even make it so that

# ok
/(::RelativePath, ::RelativePath) -> RelativePath
/(::RelativePath, ::String) -> RelativePath
/(::AbsolutePath, ::RelativePath) -> AbsolutePath
/(::AbsolutePath, ::String) -> AbsolutePath

# invalid
/(::String, ::RelativePath) -> error
/(::String, ::AbsolutePath) -> error
/(::RelativePath, ::AbsolutePath) -> error
/(::AbsolutePath, ::AbsolutePath) -> error

Perhaps those could just be fields of Path rather than actually distinct types.


Edit: nvm, removed the *(Path, String) - see below.

6 Likes