-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add conversion from cabal files #114
Conversation
Adds modules `Hpack.Convert` and `Hpack.Convert.Run` for reading a `GenericPackageDescription` onto a `Package` and running the user-facing conversion routine. The user-facing option is exposed through: ``` $ hpack --convert [cabal-file|project-dir] ``` - - - Also adds tests testing we can read cabal files generated from some of the README examples and hpack's into package.yamls that look like the original ones. Everything should be supported, including converting conditionals. I really need feedback on how to make `Hpack.Config` `Package` related `ToJSON` instances cleaner. That's the ugly bit of the code. There some cases where we run into problems in conversion. For example, the Cabal library does not expose in its data-structures if `buildable` was specified or not. To keep the output clean, I initially striped it from sections if it was true, but then empty conditional blocks could be generated. Right now it'll only output `buildable` if it's not redundant based on context. It'll also remove any empty conditional branches. This closes sol#63.
Tests are failing because of a key sorting and an encoding issue. I'll fix later today. |
Awesome!! |
dropIfGH v = v | ||
in | ||
HashMap.insert "github" (String (T.pack (drop (length githubBaseUrl) srepo))) $ | ||
HashMap.alter dropIfGH "bug-reports" $ |
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.
If it's me, I would try to avoid this kind of logic here and instead do things like this in a conversion step.
Hey, this looks really useful. But it's quite some code and my bandwidth is still limited. @yamadapc would you be willing to maintain this as a separate package? We would then add prominent references to the README etc., so that discoverability is not an issue. I think even if I would do it myself, I would at least go for two separate executables (UNIX style). |
I'm fine with doing that. I started it and ran into a couple of problems:
Those are the ones I can solve with a fork/PR, no biggie. And then there's one which I can't understand:
In all uses of the Maybe it's what these guys are talking about.. Ideas? |
@yamadapc: Do you have a |
@soenkehahn This gives you the error: https://github.com/yamadapc/hpack-convert-separate-package-with-hpack-dependency But talking with Simon, we had reached the conclusion that it'd be easier to leave EDIT A gist of the full output https://gist.github.com/9479f0bd3843e81a20ebfbd771614d1d |
@yamadapc: I see. Looking forward to this. :) |
Ok, it has been published on Hackage as People can choose to:
I'll keep it on my todo list to make it clean and have it merged back upstream. Even though it's a fork it's not hard to just cherry-pick commits back here at any point. Closing this in favor of this approach. |
We may still want to add it to the README. PRs welcome! Sent from mobile
|
@yamadapc: Just tried this out, awesome work! |
Adds modules
Hpack.Convert
andHpack.Convert.Run
for reading aGenericPackageDescription
onto aPackage
and running the user-facingconversion routine.
The user-facing option is exposed through:
Also adds tests testing we can read cabal files generated from some of
the README examples and hpack's into package.yamls that look like the
original ones.
Everything should be supported, including converting conditionals.
I really need feedback on how to make
Hpack.Config
Package
relatedToJSON
instances cleaner. That's the ugly bit of the code.There some cases where we run into problems in conversion. For example,
the Cabal library does not expose in its data-structures if
buildable
was specified or not. To keep the output clean, I initially striped it
from sections if it was true, but then empty conditional blocks could be
generated. Right now it'll only output
buildable
if it's notredundant based on context. It'll also remove any empty conditional
branches.
This closes #63.