cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Introduce Path abstraction

Open phadej opened this issue 5 years ago • 3 comments

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...)

phadej avatar Apr 06 '20 20:04 phadej

https://oleg.fi/gists/posts/2020-09-13-a-design-for-paths.html

phadej avatar Sep 14 '20 12:09 phadej

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 OsPath would be really nice. Because strong-path wraps the type from path -- which does support OsPath -- at least strong-path could likely support OsPath relatively 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.

tbidne avatar Jun 25 '25 00:06 tbidne

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

ulysses4ever avatar Jun 25 '25 01:06 ulysses4ever