github / semantic

Parsing, analyzing, and comparing source code across many languages
8.98k stars 452 forks source link

Remove typed-paths interface and use FilePath for everything #673

Open patrickt opened 2 years ago

patrickt commented 2 years ago

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.

hasufell commented 2 years ago

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:

docs:

robrix commented 2 years ago

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