-
Notifications
You must be signed in to change notification settings - Fork 56
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
(Optionally) remove transitive dependencies on Template Haskell #163
Comments
What are the issues that you're facing with template-haskell? Regarding removing the dependency on contravariant -extras, sure, I'll accept the PR. Regarding network-ip we can consider moving to a different package to represent the types. I've actually been thinking about it for other reasons anyway. |
Template Haskell needs to be run (via the internal or external interpreter) at build time. This means that code for the target platform needs to run at build time. For some special cases this can work, i.e. when compiling on the same OS to a different architecture you can use In theory, I could run a full VM to run the external interpreter on - but then the external interpreter runs in a totally different environment and the TH code might rely on that. For example, we currently use TH to fetch the current commit hash from the local git checkout. Such things won't work in that scenario. Most Template Haskell is just used for code generation, like in the examples here. But unfortunately, this still prevents a generic solution. The only generic solution is... to avoid it! :)
I'll prepare one.
How would you split that? One package per type in a monorepo setup? Or something else? |
I must admit I've learned something today thanks to your thorough answer :) The hasql-transaction update should get autoreleased once the pipeline succeeds.
I've meant that I've been considering moving to a different package to represent those types. "network-ip" hasn't been updated since 2019. "ip" seems like a viable alternative. What do you think? |
Ah, much simpler ;) So So that wouldn't help with avoiding template haskell, yet. I went through hackage, searching for Also note byteverse/haskell-ip#68. I also looked into the data types for TLDR: maybe |
Seems like the pipeline is broken because of some... other dependency on template-haskell and not high enough bounds there? Funny, kind of :D |
Yeah. We have the centric packages depending on template-haskell:
Mostly to provide the instances of It's likely that we've started something here based on some false assumptions. |
No, not really. Those build fine without template haskell - they probably need it for their tests, not to build the code. |
Check out the Lift instances on |
So two of the three files have
Edit: The |
So to be more precise: Template Haskell's splices are the evil, not quotes. |
So do we still need to fix anything here? |
Yeah, the situation is unchanged - my opening post is correct. All my observations (does X cross-compile?) where based on actually trying to build. A few months ago I tried replacing all those template haskell splices in data-dword (network-ip) and contravariant-extras with the their resultant haskell code. Pretty sure, that this made So I know this will work once we get rid of those dependencies. |
Okay. The "hasql-transaction" update is now released. Gotta make a decision on the |
Yes, |
|
Actually I've just come in to suggest that as well :) |
Should I give it a go for |
Sure! Please do |
The ecosystem is updated. Thanks for your contribution! |
Thanks a lot! |
I am trying to cross-compile PostgREST to different architectures / OS. The biggest challenge I am facing is Template Haskell, which is notoriously hard to deal with when cross-compiling. Only build-time dependencies are relevant, because running tests when cross-compiling.. is equally hard anyway.
AFAICT,
hasql
currently depends on Template Haskell twice:contravariants-extra
inhasql-transactions
:https://github.com/nikita-volkov/hasql-transaction/blob/2a9a710bd6230cb0abae84f14f852ab14fc3fa85/library/Hasql/Transaction/Private/Statements.hs#L41-L43
network-ip
in various packages (hasql
,hasql-implicits
,postgresql-binary
, ... more?), which depends ondata-dword
, which is one big piece of Template Haskell. This seems to be related to encoders and decoders for postgres'inet
type only.The usage of
contrazip2
could trivially be replaced with(fst >$< ...) <> (snd >$< ...)
.Removing
network-ip
is unlikely to happen, I guess. But maybe we could add cabal flags to each package using it, to be able to disable this dependency and the related encoders/decoders? That should have no impact on other code, right? We are not usinginet
in PostgREST anyway.I have not tried the above, yet, but would you consider accepting PRs to do the above and thus make
hasql
more friendly for cross-compiling?The text was updated successfully, but these errors were encountered: