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

redefine :r in cabal repl to run preprocessors (#1580) #1726

Closed
wants to merge 1 commit into from

Conversation

aavogt
Copy link

@aavogt aavogt commented Mar 16, 2014

This works for my purposes. It is a bit rough:

  • :r additionally prints things like Building foo-0...\nPreprocessing library foo-0...
  • there are probably cases where the original :r can be used (when no build-tools: are specified?)

@tibbe
Copy link
Member

tibbe commented Mar 16, 2014

/cc @dcoutts who's done some of the earlier work on this.

@tibbe
Copy link
Member

tibbe commented Mar 25, 2014

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\")"])
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

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 as cabal-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.

@23Skidoo
Copy link
Member

Looks good to me in general, modulo some comments. Thanks for your contribution!

@tibbe
Copy link
Member

tibbe commented Apr 7, 2014

@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.

@UnkindPartition
Copy link
Contributor

cabal should detect when no preprocessors are required, and not redefine :r in that case. Let's keep :r fast.

@tibbe
Copy link
Member

tibbe commented Dec 18, 2014

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.

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.

None yet

4 participants