-
Notifications
You must be signed in to change notification settings - Fork 29
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
Abstract filepath proposal (request for help) #35
Comments
It's GHC 9.6. |
FWIW IMO AFPP is "the next big thing" for Haskell core libraries, huge thanks to @hasufell for leading this project. |
Love your work, this looks great. I think there's a need for a |
Also I opened up https://gitlab.haskell.org/haskell/filepath/-/issues/117 with some questions that might be good to resolve before the release. |
It is a re-export. What you're looking at is a Word16 based API variant that was not accepted in bytestring, because it's too specific. This one is needed to deal with wide character bytestrings (UCS-2LE) on windows: https://gitlab.haskell.org/haskell/filepath/-/blob/master/System/AbstractFilePath/Data/ByteString/Short/Word16.hs |
Mmm IMO having to conform to If it was a separate repo, it would be very easy to use some build time tricks to get e.g. |
Has it been considered not doing a major version bump to It is clearly an improvement to be able to use this abstract datatype for FilePath manipulation but I am worried that it will cause disruption in the ecosystem for a project which doesn't yet have significant buy-in when the same feature could be introduced with a minor version bump. The API of |
I agree major bumps without breaking changes to force them are probably not worth the churn. It would be nice if there was a separate mechanism to signal "exciting release!" than that to signal "breaking release!", but that doesn't yet exist., |
It's possible. My reasoning was mainly to get more attention. And a major bump will definitely do that. PVP doesn't disallow this, at least. @Bodigrim opinions? |
Yes, I suggested something along those lines here haskell/bytestring#444 This was rejected and I think we're fine for now. |
Yes I said "another" because I had already offered a different reason there :). I would strongly advocate revisiting that decision. |
I've added some examples that prove that the current base library is unsound wrt filepaths when interacting with CP932 (which is the most common japanese encoding it seems): https://gist.github.com/hasufell/c600d318bdbe010a7841cc351c835f92 This also demonstrates that abstract filepath fixes these issues. |
Correct, PVP does not prohibit bumping a major version even if there is no material breakage. Dunno, as long as a downstream package compiles, more often than not maintainers just slap a revision to relax upper bounds and be with it, without exploring new API available. |
Yes, if you want to get more attention I recommend just telling people. Trying to communicate through major version numbers seems likely to be ineffective. I can't imagine many users doing more than just bumping the upper bound, as @Bodigrim says. |
The Reddit conversation has a decent amount of discussion about the name of the new type. (Writing this here because I find these comments are more easily found than Reddit ones.) I won't put my thumb on the scales of that discussion -- mostly because I don't trust my own instincts around naming -- but I observe that if we had local modules, this would be much easier. I've long exhausted my time budget in working on that proposal, but I would be thrilled if someone took over and got it over the line. I'm very happy to advise about what the next steps there are (but please post there, not here). |
@goldfirere I went with |
I'd rather have AFPP in with the current incarnation than wait for GHC Proposals to land (a minimum of what.. 2 years ish?), and the current spec doesn't really preclude a migration to any later GHC proposals that may land and make the authorship experience cleaner. The end user is the one that matters. Whatever you need @hasufell |
Is It may be valuable to write a tutorial for a beginner in Haskell and see if there are any wrinkles there. |
There's no way to write a total
That's already done: hasufell/hasufell.github.io#4 |
And to perhaps make the point more starkly, if there were a safe |
The main problem is that there is encoding/decoding at the FFI boundary, converting between This encoding depends on All of this is explained in the linked blog post, which will be posted after the final filepath release. To put it differently: even if we changed the |
|
@Rufflewind I would say first make it correct, then worry about ergonomics. Ergonomics are important but worrying about everything at once just makes for a confusing conversation. And correctness is the proper foundation.
Yes exactly. We need to rethink string and list literals for a variety of reasons and we should do that, but we should do that after this so as to build concensus on what the use-cases that are not handled are.
We would still need |
What is proposed here is an alternative to an existing system. Migration is already hard, but convincing people to migrate to a less ergonomic solution is even harder. More likely, people will inertially cling to the older and broken solution and "correctness" of the ecosystem as a whole will not improve as one would expect.
I never advocated for the removal of |
Even if no one migrates, this is still better to build consensus about what is needed from better overloaded literals. But, I think people will migrate. The design here is very much in line with what Python, Rust, etc. have done: we're not breaking new ground. People use the stuff over there without complaint also with less than perfect ergonomics, and so they should with Haskell too. |
|
Since the library is about improving correctness... adding Until
TH can cause issues with cross-compilation. That's why I avoid them in core libraries. In applications this should be largely fine. They allow us to fail at compile time. We can even provide quasi quoters that only accept ascii literals.
Well, this is not in my scope. I'm not going to work on GHC improving OverloadedStrings to get this project finished.
That's fine. If people don't want to migrate, then they don't. But many users have expressed interest. That's one of the reasons filepath-bytestring exists. Except that's very hard to get right in a cross-platform manner. This proposal fixes that. And provides very convenient and clearly documented functions for conversion. |
Yes, but haskell has |
Sounds like we are in a “Correctness - Ergonomics - No Fragmentation, choose 2” - situation? Are libraries with APIs dealing with paths now also expected to provide all functions twice, to please either crowd, and if they don't, programmers will have to (perceived sillily) convert? This sounds like a repetition of the String/Text/Lazy Text situation? It may be distracting, and probably hard, but a API that is easy enough that can and will be used in then common case, while still improving correctness in the corner case, so that we wouldn't need the other one (save for backwards compat) would be the bigger prize. More concretely about OverloadedStrings: my impression is that partiality of |
Library authors can decide to support only OsPath, since users can convert to and from String easily. See the API: https://hackage.haskell.org/package/filepath-1.4.99.5/candidate/docs/System-OsPath.html#g:2 I don't know what you mean with repetition of Text. Text is not the same as String and definitely not the right choice for filepaths. If you want a language with only one String type, Haskell is probably not the right choice. There is more than one String type. Haskell is about types.
I'm repeating myself, because this has been discussed over a year ago already. This proposal doesn't deprecate If you think that's a good idea, you're free to create your own proposal. The work I've put into this approach is already borderline, given that it looks like a small change. I don't want to imagine how much work it is to change base. Feel free to try, though.
The point of OsPath is not only to fix correctness issues, but also educate users. The lack of OverloadedStrings may be beneficial, since it forces users to think about their flepath literals. Unicode filepath literals are already questionable. They'll have to read the API. With quasiquoters we can make things more explicit and users can still define their own IsString orphan instance and choose the behavior they want. And there are multiple possible choices. |
Has anyone successfully built Many GHC bundled libraries do not have new versions released to Hackage (for example |
@kokobd ghc-9.6 is supposed to ship with the new filepath |
I'm also experimenting with an adjusted GHC-8.10.7 source dist that includes filepath-1.4.100.0. If it builds fine, I'll upload it somewhere. |
IMO old GHC + newer libraries should be a thing we do on a regular basis, so long as we are supporting older GHCs for all. There should be regular workflow for that. |
This is done. GHC 9.6 will hopefully ship with it. |
Motivation
The abstract filepath proposal strives to improve filepath handling in Haskell. The original proposal is written down in the GHC wiki and suggested implementing this in base.
Since this would break a lot of real world code, we (CLC and filepath maintainers) decided to implement this in "user-space", as in: only in
filepath
(a core library shipped with GHC). That means base will not use these new filepath types for the foreseeable future, but other core-libraries can.The main benefits compared to
type FilePath = String
are:Previous discussions
Previous work
ShortByteString
: Mergeshortbytestring
package back intobytestring
wrt #444 haskell/bytestring#471Current state
The code is ready for release, PRs 3. and 4. can be merged in a timely manner (those are the minimum requirements to be able to use it).
Next steps
The idea is to get this release into GHC
9.4or 9.6 (@Bodigrim I actually forgot which one). Users on older GHC will however be able to upgrade to the newer filepath anyway, because it's not tied to base.After that, we need to market this new API and request core libraries maintainers to support AFPP (either as additional API or as the main API).
Some dicussions and PRs:
AbstractFilePath
haskell/directory#138AbstractFilePath
haskell/process#252AbstractFilePath
commercialhaskell/path#189This isn't a formal tech proposal, since the new API has been merged and will be part of the next filepath release. However, migrating the ecosystem can only be a joint effort. I'd imagine the next packages that need adoption are directory and process at least. I can't do all these migrations on my own, unless I intend to burn out.
I'm not sure what exactly I'm asking, but I talked with @david-christiansen during ZuriHac that this needs wider support. So I'm dropping this thread here.
I intend to write a blog post after the release that summarizes the work done, outlines how to use the new API and suggests migration strategies.
The text was updated successfully, but these errors were encountered: