I have a package with the following structure (well, this is greatly simplified, but ...)
app/ src/ Main.hs data/ data.txt app.cabal Paths_app.hs Setup.hs
In Paths_app.hs, I have:
module Paths_app where getDataFileName :: FilePath -> IO FilePath getDataFileName = return
and in Main.hs I have:
module Main where import Paths_app main = do file <- getDataFileName "data/data.txt" data <- readFile file putStrLn $ "Your data is: " ++ data
the relevant parts of my app.cabal file are as follows:
name: app version: 1.0 build-type: Simple data-files: data/data.txt executable foo build-depends: base, haskell98 main-is: Main.hs hs-source-dirs: src
This builds fine (using cabal configure followed by cabal install ), but the executable complains that it cannot find the data.txt file. I tried replacing the string
file <- getDataFileName "data/data.txt"
from
file <- getDataFileName "data.txt"
but the same thing happens. Is there something obvious I'm doing wrong?
haskell cabal
Chris taylor
source share