haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 691 forks source link

QuasiQuotes should trigger building TH libraries #4580

Closed duog closed 7 years ago

duog commented 7 years ago

I don't fully understand the nuances, but in several places in Distribution.Cabal.Simple.GHC[(JS)] the extensions specified in a cabal file are checked for TemplateHaskell, and if it is present then object files are build for ghci, to enable the template haskell to be typechecked. By the same logic, the presence of QuasiQuotes should trigger the same behaviour.

ezyang commented 7 years ago

Do you have an example program where this is causing a problem? I actually don't think it is necessary to build TH objects for just QuasiQuotes, because QuasiQuotes by themselves cannot trigger splices to build. For this very reason, QuasiQuotes are enabled on a stage 1 GHC compiler, when TemplateHaskell is not (that is why I added this pragma in the first place!)

duog commented 7 years ago

I may be missing something, but I'm pretty sure QuasiQuotes can trigger splices to build, see examples in the docs here, are you thinking of TemplateHaskellQuotes?

This patch contains and fixes a test case that failed due to a QuasiQuote needing an object file.

I have briefly tried to get language-quote-0.12 to fail to build with

cabal unpack language-c-quote-0.12
cd language-c-quote-0.12
cabal install --only-dependencies
cabal configure --disable-shared
cabal build

However, I can't see how to cajole ghc+cabal into not producing .dyn_o object files. I believe that if one could find such an incantation then this error would surface.

hvr commented 7 years ago

@ezyang are you sure you don't mean TemplateHaskellQuotes?

EDIT: I just saw @duog's comment who actually asked the same thing...

ezyang commented 7 years ago

Yes, you are right! So this is a legitimate bug, but it also sounds easy to fix: just find where we have TemplateHaskell hard coded and generalize it. @duog would you like to take a shot?

duog commented 7 years ago

Yes I'd be happy to.

On Thu, Jul 6, 2017 at 1:00 PM, Edward Z. Yang notifications@github.com wrote:

Yes, you are right! So this is a legitimate bug, but it also sounds easy to fix: just find where we have TemplateHaskell hard coded and generalize it. @duog https://github.com/duog would you like to take a shot?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/haskell/cabal/issues/4580#issuecomment-313266593, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSFHYd9vV8MziN-vM-6zgSzo_wUUwq2ks5sLDGzgaJpZM4OLvHr .

ezyang commented 7 years ago

OK, I added you to the collaborators on Cabal. Looking forward to your patch!