Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

lukel97
Copy link
Contributor

@lukel97 lukel97 commented Jul 8, 2020

Taken from #6241

@lukel97
Copy link
Contributor Author

lukel97 commented Jul 8, 2020

cc @phadej

@lukel97 lukel97 force-pushed the json-bytestring branch from e5e36e3 to c9cb617 Compare July 9, 2020 10:45
Cabal/Distribution/Utils/Json.hs Outdated Show resolved Hide resolved
Cabal/Distribution/Utils/Json.hs Outdated Show resolved Hide resolved
| JsonNull
| JsonNumber !Int
| JsonObject [(ByteString, Json)]
| JsonString !ByteString
Copy link
Collaborator

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 in JsonObject (as these are most likely static), and would use String for JsonString (as it looks like most producers are prettyShow or alike).
    • I'd like it to be ShortText, but if most producers atm are producing String, that would be silly. Yet, there could be a comment to eventually change it to ShortText (Path abstraction is related: Introduce Path abstraction #6667)

Copy link
Contributor Author

@lukel97 lukel97 Jul 9, 2020

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

Cabal/Distribution/Utils/Json.hs Outdated Show resolved Hide resolved
Cabal/Distribution/Utils/Json.hs Outdated Show resolved Hide resolved
@lukel97 lukel97 force-pushed the json-bytestring branch 2 times, most recently from d4dbd48 to 0fe8abf Compare July 9, 2020 17:23
@phadej phadej added this to the 3.4.0.0 milestone Jul 10, 2020
@lukel97 lukel97 force-pushed the json-bytestring branch 2 times, most recently from bc9558e to 7e92f25 Compare July 10, 2020 12:48
@@ -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
Copy link
Collaborator

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

Copy link
Contributor Author

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?

@phadej phadej modified the milestones: 3.4.0.0, Considered for 3.6 Jul 13, 2020
@phadej
Copy link
Collaborator

phadej commented Jul 13, 2020

I'll postpone merging this after I cut the 3.4 branch, which I hopefully will manage to do today.

@lukel97
Copy link
Contributor Author

lukel97 commented Jul 21, 2020

Failing build looks flakey

@DanielG
Copy link
Collaborator

DanielG commented Feb 14, 2021

Now that 3.4 has been released, what's the status of this PR?

@jneira
Copy link
Member

jneira commented Feb 14, 2021

uh the tag is in this repo but the download page has not been updated?
https://www.haskell.org/cabal/download.html
still 3.2 there afaics

@fgaz
Copy link
Member

fgaz commented Feb 14, 2021

It may be because cabal-install 3.4 is still unreleased

@jneira
Copy link
Member

jneira commented Feb 14, 2021

oops sorry even tag is for Cabal and no cabal-install

@fgaz
Copy link
Member

fgaz commented Mar 3, 2021

@bubba could you rebase?

@fendor fendor mentioned this pull request Jul 8, 2021
@gbaz
Copy link
Collaborator

gbaz commented Aug 12, 2021

Closing in favor of the rebased pr.

@gbaz gbaz closed this Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants