Introduce Path abstraction
Like the one already used in hackage-security.
We want to have Absolute rooted Paths, but also more specific like StoreDir, or PackageDir and ProjectDir which all would make handling paths a bit more robust.
It would helped a lot in my recent sdist refactor. Getting relative to PackageDir paths is tricky, not sure if I haven't missed any.
I however suggest to store these (file paths) in native way. (Not in POSIX like paths library does), because I'm quite sure that conversion from Windows to Posix and back won't roundtrip on fancier paths there might be. Therefore we might need separate PosixPath for tarballs etc if we end up needing such notion (and we might, index files...)
https://oleg.fi/gists/posts/2020-09-13-a-design-for-paths.html
I am interested in this issue, motivated by https://github.com/haskell/cabal/issues/11004. I see hackage-security has a custom Path type, which would work, though I wonder if there are any libs that would save some work. I am aware of:
| feature/lib | path | paths | strong-path | hpath |
|---|---|---|---|---|
| Dir vs. File | ✅ | ❌ | ✅ | ❌ |
| Abs vs. Rel | ✅ | ✅ | ✅ | ✅ |
| Typed Rel | ❌ | ✅ | ✅ | ❌ |
| OsPath | ✅ | ❌ | ❌ | ❌ |
| Portable | ✅ | ❔ | ✅ | ❌ |
| Maintained | ✅ | ❔ | ❔ | ❔ |
First, I've only really used path, so do correct me if there are mistakes. Some notes:
- Support (or at least a potential migration) to
OsPathwould be really nice. Becausestrong-pathwraps the type frompath-- which does supportOsPath-- at leaststrong-pathcould likely supportOsPathrelatively easily. -
Portable: Meaning supports windows and posix. -
Maintained: I just looked at recent commits / hackage revisions.
For cabal, I think we really want typed relative paths, and probably directory vs. file distinction (maybe you don't need an explicit type var if you have Typed Rel?).
In any case, the only library here that seems to have the right feature set is strong-path and maybe paths, though I'm not sure how well-maintained they are. Perhaps a bespoke solution like hackage-security is needed.
FTR we recently a had a sort of an overhaul around paths with https://github.com/haskell/cabal/pull/9718 (and follow-ups), which was a bumpy ride. In particular, https://github.com/haskell/cabal/blob/f6863c07cd311910625323c453efda32592f100f/Cabal-syntax/src/Distribution/Utils/Path.hs#L99