-
Notifications
You must be signed in to change notification settings - Fork 18
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
cabal-docspec: can it do CPP preprocessing before running examples? #120
Comments
I'd say it just cannot work reliably. proper |
Actually, Maybe
will work. |
I was assuming CPP extension specified in the cabal file might work. But it seems I have to specify And then it worked! Thanks! |
Well, that is a bug. I will fix that. (though in general I advice against having |
Thanks, will keep that in mind. Did not notice it till now. |
I used |
but that messes up error reporting (as it reports invalid lines then). It's really not perfect. I'd suggest to not go too crazy with CPPing tests. You make your own (and my) life harder. |
Not going crazy, there is just one reason to use it. Our released module imports an internal module and doctests are in the internal module which has a setup section. Now I want to expose this setup section to users who may want to run the examples. I do not want to duplicate the setup section because it will always lead to inconsistency. You can see what I did here. If I do not use block comments, the problem was that the Another alternative is that I duplicate the full setup section in the two parts of the conditional. I am getting correct line number info in error messages. Maybe the GHC option is not affecting docspec? And it is able to handle the line number stuff? I first saw the line numbers showing up in haddock when I suppressed it. Maybe docspec was dealing with it fine? |
In error messages GHC produces I still think you try to do too fancy stuff with CPP, and run into limitations of CPP not being "haskell preprocessor". Sadly, GHC folks don't try to design solutions to problems like these (ghc-proposals/ghc-proposals#283 is dormant (bit opened in 2019!), but if something like that is implemented one could exports qualified modules, so a Haskell language construct could be used to do what you try to do with CPP). I'm not going to spend time on problems better solved elsewhere. CPP is a band-aid at best. |
You are right about the GHC error messages. It's a no go. So there is really no good solution to this problem. |
Is there some way to be able to use CPP to produce code for the setup section?
This works with haddock, but cabal-docspec does not seem to be able to use the
#include
. Is there some option that I can use, or this just cannot work.The text was updated successfully, but these errors were encountered: