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
Template Haskell fails when signatures stack up #5634
Comments
Yeah, this should work. What was the error message you got? |
|
OK, I have a guess as to what's going on (we're not correctly populating the dependent libraries list when we typecheck indefinite packages). I won't be able to look at this in detail until the weekend. This is probably a GHC bug, rather than a Cabal bug. |
Nevermind, it's a Cabal bug.
For some reason, it doesn't decide to actually build the instantiated component. |
I've recently encountered an issue along these lines (maybe even the same problem). Here's my test repo https://github.com/LightAndLight/backpack-test. I don't even have to use any template haskell features, the presence of the pragma is enough to cause the issue. I've used this knowledge to get around the issue in my actual code. My current heuristic is "don't use template haskell in modules that (either directly or transitively) depend on a signature". |
This is actually really inconvenient as backpack is a promising method of abstraction for my current project. It might be more productive for me to help fix this than find ways to get around it. @ezyang If you have the time, would you be able to point me in the right direction for debugging these errors, and potentially upstreaming a fix? |
I have reviewed the code for linked component to ready component, and I think the problem is that we are not instantiating fully definite includes inside indefinite packages. Should be easy enough to fix. |
I threw up a patch but I have not tested it at all. Will test over the weekend. |
@LightAndLight I think your problem is a different one, as it's not fixed by the posted PR. |
@ezyang No worries |
Hi,
There is definitely some weird interplay between Template Haskell and backpack that I don't totally understand. Even when the two seem completely unrelated, I'm getting errors. Consider the following example:
Example
Let's assume this is the cabal file:
The individual files are quite simple.
impl/Impl.hs:
sig-with-th/Sig.hsig
sig-with-th/THFuns.hs
th-backpack-failure/Go.hs
th-backpack-failure/Unused.hsig
Tests
Building the above fails with an error message that (I think) indicates that Template Haskell and Backpack don't play nicely together. But, if you remove the line
signatures: Unused
from the cabal file, it builds just fine. Alternatively, you can remove the linesmixins: sig-with-th requires (Sig as Impl)
andsignatures: Sig
and it builds just fine too.Another work-around is to add a new library stanza to the cabal file, like so:
Then, change the main library stanza by removing the
mixins
line and depending onintermediary
instead ofsig-with-th
andimpl
. This builds just fine too.Thoughts
It seems like signatures are being piled together in a way that doesn't support template haskell. In other words, I really wanted it to be the case that when the main library instantiated
sig-with-th
, that import would be treated as if there were no backpack components at all (after all, all the backpack holes have been filled in). Then, any Template Haskell imports from that import are totally fine, even if I add a signature to the main library.The
intermediary
option is a definite work-around, but it would be better to not have to use such tedious boilerplate.The text was updated successfully, but these errors were encountered: