After having picked up stack as a step in starting to write non-trivial haskell programs (larger than a single file) I've run across the problem of not knowing how to get stack to recognize .ini files and such. It doesn't seem to fit anywhere in the .cabal or stack.yaml files.
For clarification: after running stack build/install, the folder with the generated .exe doesn't have the resources, and so of course the program crashes with a bunch of IO errors (file not found).
There are two options. The one I assume you're looking for is data files. To do this, you'll essentially:
data-files field in your .cabal file so that they are installed when building your packagePaths_package_name module to your other-modules in your .cabal file (replace package_name with your package name)Paths_* module where neededgetDataFileName :: FilePath -> IO FilePath function to get the absolute path to the data file you needThe alternative is to embed the data file contents inside the executable itself using Template Haskell, such as with the file-embed package.
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