← Back to context

Comment by anyfoo

4 years ago

It really depends. Do you usually keep hostnames as strings? URLs? JPEGs? Why or why not?

Sure, a browser will hopefully quickly parse that URL and break it up, an image viewer will do the same with a JPEG. Will anything that's only interested opening/displaying that URL or JPEG, through a library or external program?

POSIX paths are actually remarkably simple in structure[1]. The only caveat is equality and normalization: Without normalization, a path a might be equal to a path b while their representations differ, e.g. "/etc/foo" and "/etc/bar/../foo". But this is the same whether you have a string or a list of strings, you need to normalize in whatever representation you choose to check for equality.

[1] Almost shocking myself, even Haskell defines its primary FilePath type literally as "String".