-
Notifications
You must be signed in to change notification settings - Fork 841
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
Change 'stack ghc' to provide package context #1737
Conversation
7b4959b
to
dd5de89
Compare
Thanks for working on this. One issue is that since it uses the default build options, info from all the executable and library components will be used (and not from test / benchmarks). Sometimes the info from two packages don't work well together, for example, if one imports I actually don't think this is necessary, it should already be possible with |
Hrm, actually |
Oh, I see. Didn't read that yet when I replied. I guess it would fail on certain projects. As far as So I think what has to happen to fix what you're talking about is to go from a
Well, it produces the same package-id flags that would be produced with a simple |
This is like the 'stack ghc' command, but adds package arguments similar to the ones 'stack ghci' would add.
Also, --add-ghci-packages is now available to do the same thing for 'stack exec'.
I did a |
So is How about adding something like this as a subcommand of Sorry to push back on code you've worked on, but we want things to fit together nicely into a cohesive whole. |
No it isn't. For two reasons:
There's a miscommunication going on here -- you're looking at the wrong patch! Look at a diff between my master and the master of commercialhaskell -- there is no such name anymore. I removed it before even submitting the pull request, although I didn't amend my git history. (I guess that was a mistake, I should have submitted a single commit.) Here is the pull request with all four commits combined: https://github.com/commercialhaskell/stack/pull/1737/files What I did in the final version of the pull request is modify the default behavior for But it does seem to me that modifying the default behavior of
That's OK. |
Ah, I see! More food for thought on this: #1208 #1388
You actually probably do want that, if you want cabal CPP macros to work.
Yeah, it's better to leave out the previous attempt, to avoid confusion.
Yeah, that's why we need to know which targets the user cares about. This requires specifying or inferring which packages / components to use as targets. #1361 is relevant, we should be able to determine the target the user cares about, based on which file they are compiling. |
Ha! So it should. Turns out that's another bug in flycheck+stack! The cabal CPP macros indeed do not work in flycheck. (Of course, just adding the argument isn't enough to fix it, because the file also has to be generated (and, ideally, removed) -- another problem for a Seems about right. One kink though is that Probably it's too much for stack to guess the original filename -- flycheck should supply more info (although this breaks compatibility with existing flycheck installs). But the functionality of mapping filename -> cabal target still seems to fall into the purview of stack. Seems to me like a possible plan would be something like this:
(That creates a weirdness where Thoughts? |
So I got cabal_macros.h included, fixing cabal CPP in flycheck, but I had to change some things around to do so. Specifically, that |
Hey, sorry for letting this languish! Things got busy. I hope you're still keen on doing some work on this?
True! How about "stack query targets-for FILE" and "stack query default-target-for FILE`. It doesn't really fit into query's current tree-of-data schema, but it's experimental, so we can change how it works (ideally maintaining compatibility with the existing queries). As already mentioned, the implementation can be shared with #1361
The targets parser is already pretty overloaded. However, none of our existing target syntax allows ".hs" or ".lhs" (well except dirs, and in that case it's unambiguous what the user means), so I think it'd be fine to just take haskell files. It'll be quite great to be able to do
I think that's fine. Retrospectively, using
Seems reasonable! You could also just demand that the user updates their stack version since this will work quite a bit better. |
Going to go ahead and close this, thanks for the discussion! I opened #2053 to track further work here |
This patch is necessary for me to use
flycheck
(which callsstack ghc
internally) on a project that usescryptonite
with a package database that containscryptohash
.Without it, I get flycheck errors like this:
Related: flycheck/flycheck-haskell#52