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
redefine :r in cabal repl to run preprocessors (#1580) #1726
Conversation
/cc @dcoutts who's done some of the earlier work on this. |
I will review this tonight I hope. @23Skidoo does this look OK to you? |
let dotGhciPath = autogenModulesDir lbi </> "ghci" | ||
rewriteFile dotGhciPath (unlines | ||
["-- override :reload", | ||
":def! r (\\_ -> return \":!cabal build --only-preprocess\\n::reload\")"]) |
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.
Should this be :def! r
so this works if the user actually types the full command? Or does :def! r
actually use the same lookup rules that makes :r
mean :reload
?
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.
At least in my ghci (7.6.2), macros only work by the exact name they are defined with. Furthermore :def! reload (\_ -> return "somethingNotInScope\n::reload")
ought to break :reload
, but it seems the built-in :reload
is used instead.
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.
Please read all of https://ghc.haskell.org/trac/ghc/ticket/8113, including the other ticket linked to at the end.
We can probably only make this work correctly in GHC 7.8. So either
- we guard this behind a GHC version check and only pass the extra ghci script to GHC-7.8 or later or
- we define the macro as
reload
when using GHC-7.8 or later and ascabal-reload
otherwise.
The latter will let all users use the features, but it won't magically work correctly with e.g. the Haskell emacs mode.
Looks good to me in general, modulo some comments. Thanks for your contribution! |
@aavogt this would be great to have in 1.20. There are mostly minor comments and some testing needed to make sure this work on different GHCs. |
cabal should detect when no preprocessors are required, and not redefine |
I still want something like this in Cabal. Since there have been outstanding unaddressed review comments for a while and I'd like to keep our pull request queue clean, I will close this for now. |
This works for my purposes. It is a bit rough:
:r
additionally prints things likeBuilding foo-0...\nPreprocessing library foo-0...
:r
can be used (when nobuild-tools:
are specified?)