-
Notifications
You must be signed in to change notification settings - Fork 696
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
Convert Json module from String to ByteString #6948
Conversation
cc @phadej |
Cabal/Distribution/Utils/Json.hs
Outdated
| JsonNull | ||
| JsonNumber !Int | ||
| JsonObject [(ByteString, Json)] | ||
| JsonString !ByteString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of strings are used here. I'd use either ShortText
or String
inside Json
type.
E.g. package-ids, unit-ids are backed up by ShortText
(and they are in UTF8, so if they don't need escaping they can be used as is).
Yet, currently filepaths are FilePath
i.e. String
.
Here are two issues:
- The keys and strings are textual
- double conversions. Thus I'd use
ShortText
for keys inJsonObject
(as these are most likely static), and would useString
forJsonString
(as it looks like most producers areprettyShow
or alike).- I'd like it to be
ShortText
, but if most producers atm are producingString
, that would be silly. Yet, there could be a comment to eventually change it toShortText
(Path abstraction is related: Introduce Path abstraction #6667)
- I'd like it to be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really a double conversion if this all gets converted to a ByteString
at the end of the day? As far as I can see for JsonString
, all the filepaths etc. will go from String
-> ByteString
, and then once it's in a ByteString
the builder means it will be cheap to insert it and move it around
d4dbd48
to
0fe8abf
Compare
bc9558e
to
7e92f25
Compare
@@ -349,7 +349,7 @@ library | |||
|
|||
if !impl(ghc >= 7.8) | |||
-- semigroups depends on tagged. | |||
build-depends: tagged >=0.8.6 && <0.9 | |||
build-depends: tagged >=0.8.6 && <0.9, bytestring-builder >= 0.10.8 && <0.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong as is, but I'll fix it before merge. One can have older bytestring on newer GHC, though that is contrived corner-case. But Cabal should be exemplary in own definition :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need a newer bytestring on an older GHC here though?
I'll postpone merging this after I cut the 3.4 branch, which I hopefully will manage to do today. |
Failing build looks flakey |
Now that 3.4 has been released, what's the status of this PR? |
uh the tag is in this repo but the download page has not been updated? |
It may be because cabal-install 3.4 is still unreleased |
oops sorry even tag is for Cabal and no cabal-install |
@bubba could you rebase? |
Closing in favor of the rebased pr. |
Taken from #6241