Cabal: how to add a text file to build dependency

I am using a simple text file to generate some code with TemplateHaskell and runIO.

...    
curdir <- runIO $ getCurrentDirectory
addDependentFile $ curdir ++ "/spec.txt"
bs <- runIO $ BS.readFile "spec.txt"
...

Everything works fine when used with ghci. The problem is that cabal has no idea that I need this file to create, and I get it when I do cabal build.

Exception when trying to run compile-time code:
  spec.txt: openFile: does not exist (No such file or directory)
+5
source share
1 answer

take a look at the flag data files:

http://www.haskell.org/cabal/users-guide/developing-packages.html#accessing-data-files-from-package-code

By the way, I recommend EclipseFP for your assignments. It provides a convenient way to edit cabal file. so i can find this flag. It really reduces trivial work.

http://www.haskell.org/haskellwiki/Haskell_IDE#EclipseFP_plugin_for_Eclipse_IDE

=============================================== ==============================

.

, . ghc openFile .

, openFile .

" "

, , .

setCurrentDirectory curdir getCurrentDirectory

. ,

+2

All Articles