I'm working on a Haskell project (Happstack server + Blaze HTML/front-end as main libraries) and I want to add a static data directory.
Looks like you can do so with Cabal using the auto-generated Path_<package_name>
module. So in my example, the package is called new-website
, so that module should be called Paths_new_website
.
Link to Cabal docs re: a custom package's Paths_pkgname
module.
From the command line and using cabal repl
, I am trying to confirm that I'll have access to the Paths_
module. However, I'm finding that the Paths_new_website
module isn't being imported by Cabal when running cabal_repl
.
Here's a link to some relevant code and terminal output via a gist.
Does anyone have experience with this, getting a finicky Paths_ module to load with my package? I suspect this may be a question of lexical scope between Main.hs
(the primary source file) versus the context in cabal_repl
...
Paths_*
modules are only generated by Cabal during builds. If you're running the package using GHCi
or cabal repl
then they simply won't exist and your code will fail with "Cannot find module" errors.
There's a sneaky development mode trick, though: just build your own Paths_*
module and place it in your haskell-source-dir
. During development, GHCi
will load that module and you can adjust its exported symbols to make your development environment fly. During build, Cabal will overwrite your module with its own and take into account the final information needed to build the Paths_*
module.
So in this particular case, just make a file src/Paths_stackbuilders.hs
and provide it a relative path to the datadir
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With