-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"one" </> "/two" == "/two" needs explanation #49
Comments
So the docs for |
It would be nice if the package exposed a function which combines the two paths as "one/two". There is such a function internally ( |
What are you using that function for? Any examples? I'm not totally against it, but I'd like to understand in what circumstances it should be recommended. |
I have a function which may return an absolute URL path (eg. So, in Haskell language: dump :: FilePath -> FilePath -> ByteString -> IO ()
dump basePath assetPath body = writeFile (basePath </> assetPath) body
main = do
dump "./dist/" "/assets/app-1234.js" "..." I would rather have two functions which are clearly documented than one which tries to guess what my intentions are. |
Without having examined all the examples for If @wereHamster's operation I think is best viewed as splitting the absolute path |
Maybe we should rewrite combineAlways a bit, and enforce the following rules:
It would prevent current invalid results such as:
@wereHamster: please note that joinDrive is only a synonym for combineAlways since filepath-1.4.0. From the 1.4 changelog:
Edit: a consumer of this new version of combineAlways would be Cabal, in the file
|
I've clarified a lot, added the intuition from @rwbarton (in Haskell form), put all the docs under
I don't think exposing
This is a lexical operation, rather than a filepath one. |
My inclination is to close this ticket now the docs are fixed - anyone still think it would be good to have "something else", and if so, what that something else should do (not in terms of code, more the idea behind it). |
I think the new comment might be a bit easier to read if you swap the two Haskell bits; then it reads more like a definition of Aside from that, I agree with closing this ticket. |
You mean make it:
? If that seems clearer to you, I'll go with that. |
Yes, exactly. |
Done, thanks for the suggestion. |
The same problem applies to |
Doesn't the new comment conflict with |
So this behavior seems already sufficiently documented. I'm providing a PR for discussion, which exposes an alternative |
I also just discovered:
This is incorrect on windows, since
But from what I understand it's relative to the current device? |
On Windows you have drive-relative paths and path-relative paths. |
FWIW, I still think exposing |
I think one solution could be to return a sum type of cardinality 3, then mark isAbsolute/isRelative as deprecated (for a couple years or indefinitely). My opinion is that we should ultimately define platform specific functions that are unambiguous. The platform agnostic module could then:
|
I disagree, since I think that's a good way to have none of the ecosystem work on Windows. In my view, working transparently across platforms is way more important than high fidelity. But its your choice now :) |
We already expose platform specific functions via the qualified modules. If someone imports them without understanding the consequences, they already break cross platform support. The idea is rather that those platform specific modules can have more specific functions (not existing in the "cross" module) that people can use when implementing their own platform specific logic. I don't believe we will ever be able to cover all of the use cases, as the relative path issues show. Now, users who want more details about their windows paths, could easily get it without re-implementing stuff, which is rather error prone. |
Nothing in the documentation indicates that behavior: http://hackage.haskell.org/package/filepath-1.4.0.0/docs/System-FilePath-Posix.html#v:-60--47--62-
The text was updated successfully, but these errors were encountered: