-
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
Improve normalise #12
Comments
I had a brief look at the tests in https://github.com/ndmitchell/shake/blob/master/Test/FilePath.hs#L33-L62 Notable discrepancy: Special handling of trailing dots was added to System.FilePath in 3815668. |
Looking at the trailing slash behaviour of normalise, I'm not certain what the right answer should be. Is going from trailing slash to not too much change for normalise? |
Since |
Quite possibly, I'd like the Shake and non-Shake versions to end up equivalent where they overlap - and some changes to the Shake version is fine. |
So I think my underlying uneasiness all comes down to what In Shake I jumped for preserving the presence/absence of a trailing slash, in FilePath we seem to be preserving directory information. I'm still trying to figure out in my head which is better. |
There are lots of things here that aren't quite right, comparing to the Shake version (which also has a few minor trailing slash and drive issues). A few examples on
I think the "right" solution is probably to rethink the whole library to be based around:
Where we rely on the property Does anyone (e.g. @thomie) think that seem sensible? Or a bad idea? Or too disruptive? |
Those are all invalid filepaths:
I also get a different result for this one:
But I like your idea. |
By Since the filepath library is one of the GHC Core libraries it's very important that we don't break reverse compatibility other than for bugs, so we'll have to support invalid paths forever (I personally think that's a good thing, in certain circumstances things which would otherwise be invalid can be useful to do some subset of operations on). We also can't depend on system-filepath, since that isn't a Core library (it also does a few things I'm not a fan of). I'm not suggesting we expose the |
Ok, I was just confused for some reason. Still, it's not a valid filepath, so normalise can do whatever. Even core libraries can be changed, after an accepted proposal on the libraries list, but I see what you're saying. It would be nice if the section "Should FilePath by an abstract data type?" from the old readme would come back, with an explanation why invalid paths can sometimes be a good thing. |
Agreed, I should resurrect that section, but make it up to date (before it was all about proposals, and before system-filepath existed). |
I've updated the README with an abstract filepath section. Work still needed on normalise. |
Idea is to do this after #53. |
Should |
@Rufflewind - yes, probably. That said, there are plenty of holes in normalise that could do with being addressed... |
both paths are invalid, yet Maybe |
Just hit this issue today. Could we possibly fix at least this inconsistency, if a larger rewrite is not on cards? Another helpful option would be at least to document known caveats with existing |
Normalise is a mess. I'm not even sure what are all the expected properties. Rewriting it in-place isn't possible. We'll have to rename the function and deprecate the old. |
When reviewing the Shake normalise function, I realised the implementation I had was all wrong. I should backport the appropriate Shake tests to the FilePath library and see if that also needs improvements.
The text was updated successfully, but these errors were encountered: