semantic icon indicating copy to clipboard operation
semantic copied to clipboard

Remove typed-paths interface and use FilePath for everything

Open patrickt opened this issue 3 years ago • 2 comments

Though FilePath is very flawed, especially on Windows, typed paths were a failed experiment. They did not actually catch any bugs; the best thing they did was expose some very weird behavior in certain functions, ones that we were unable to change (without huge renovations) lest command-line invocations break. There is a new FilePath type coming, one based on ShortByteString and officially blessed by a GHC working group, and we should just switch back to FilePath so that we can transition to that when possible.

patrickt avatar Mar 25 '22 16:03 patrickt

My package hpath, which will transition to AbstractFilePath when it rolls out, is a fork of the path package and adds the distinction of absolute/relative only: https://github.com/hasufell/hpath

Right now it only works on bytestring and unix. I have an experimental branch that adds windows support and uses AbstractFilePath: https://github.com/hasufell/hpath/tree/abstract-filepath

It also contains a rather big module with its own IO functions implemented from scratch: https://github.com/hasufell/hpath/blob/abstract-filepath/hpath-io/src/HPath/IO.hs

If you're interested in that approach, I'm open to discuss API. GHCup will switch back to it once all the transitions are ironed out, but it doesn't have any other user afaik.


Edit: I also happen to be the filepath maintainer and the implementor of AFPP.

If you want to test it, check out:

  • https://github.com/hasufell/file-io for reading/writing files (use the cabal.project contained in that repo, which uses unix/win32 patches)
  • clone https://github.com/haskell/filepath/pull/103 and build the haddocks to get an idea of the upcoming API

docs:

  • https://hasufell-stuff.eu-central-1.linodeobjects.com/filepath/index.html
  • https://hasufell-stuff.eu-central-1.linodeobjects.com/file-io/index.html

hasufell avatar Apr 01 '22 08:04 hasufell

@hasufell: This is very cool; thank you for sharing!

robrix avatar Apr 21 '22 13:04 robrix