Reputation: 6431
Let's say I'm building a web application with haskell as both server-side and client-side code. During the build phase, I want to compile server-side code with ghc
and client-side code with some haskell to js transpiler.
The haskell transpiler tools expose an executable that I need to feed with .hs
files and it will compile to .js
files. How do I specify in cabal to run external programs during the build phase? I can see, that the UserHooks
field buildHook
has the return type IO()
, so I can theoretically probably use for example shelly library to execute shell code to run the transpiler, but I don't know if this is the cleanest solution.
Upvotes: 2
Views: 140
Reputation: 7536
Here's a post i wrote about solving the same problem.
It's usually a bad idea to use custom Setup files since there is no way to handle dependencies for it, and unless you install these dependencies first you can't even sdist
.
I find it works well to have an optional command line option that precompiles code when the webserver starts.
Another option is to have a makefile that compiles both.
Upvotes: 1