
In a project I have currently some program text embedded as String in the source code. I like to move that to an extra file, such that I can test the program without running the Haskell code and such that non-Haskell programmers can adapt the text. However, I hesitate to use the Data-Files feature of Cabal since this would mean that I can test the Haskell code only after installation of the whole Cabal package including the text file. Is there a way to use 'cabal repl' with the local version of the text file? This would mean there must be a different variant autogen/Paths_mod.hs, maybe the same file name but in a different directory that is only passed to GHCi by 'cabal repl'. Manageable but certainly surprising? Maybe only available by a new option like 'cabal repl --local-dirs'. More difficult: Can even 'cabal build' incl. dist/build/prog/prog and 'cabal run' use local data files per request? Certainly not, since dist/build/prog/prog shall just be installed by 'cabal install'. Alternatively, is there a way to tell GHC to include a file in the executable and provide access to its content? Would there be support in Cabal for this feature?

One of the tracking bugs we have for this issue: https://github.com/haskell/cabal/issues/4120 Note that the data file directory can be overridden with environment variables, that might be good enough to work around. It would be really nice if inplace data files worked. It is a little tricky to do, since the installed layout may not match the inplace layout, but maybe it would be OK if this were just opt in. Edward Excerpts from Henning Thielemann's message of 2017-03-03 11:02:30 +0100:
In a project I have currently some program text embedded as String in the source code. I like to move that to an extra file, such that I can test the program without running the Haskell code and such that non-Haskell programmers can adapt the text. However, I hesitate to use the Data-Files feature of Cabal since this would mean that I can test the Haskell code only after installation of the whole Cabal package including the text file.
Is there a way to use 'cabal repl' with the local version of the text file? This would mean there must be a different variant autogen/Paths_mod.hs, maybe the same file name but in a different directory that is only passed to GHCi by 'cabal repl'. Manageable but certainly surprising? Maybe only available by a new option like 'cabal repl --local-dirs'.
More difficult: Can even 'cabal build' incl. dist/build/prog/prog and 'cabal run' use local data files per request? Certainly not, since dist/build/prog/prog shall just be installed by 'cabal install'.
Alternatively, is there a way to tell GHC to include a file in the executable and provide access to its content? Would there be support in Cabal for this feature?

On Fri, 3 Mar 2017, Edward Z. Yang wrote:
One of the tracking bugs we have for this issue: https://github.com/haskell/cabal/issues/4120 Note that the data file directory can be overridden with environment variables, that might be good enough to work around.
It would be really nice if inplace data files worked. It is a little tricky to do, since the installed layout may not match the inplace layout, but maybe it would be OK if this were just opt in.
Thank you for the pointer to the ticket. I didn't find it myself because I did not expect that the problem has to do with Nix. :-) I see that the problem is hard. Maybe paths relative to the executable could be another option?

Yes, that's possible, though a little difficult to implement portably (c.f., https://hackage.haskell.org/package/executable-path-0.0.3/docs/System-Enviro... ). File a bug, if you like? Edward Excerpts from Henning Thielemann's message of 2017-03-03 11:45:55 +0100:
On Fri, 3 Mar 2017, Edward Z. Yang wrote:
One of the tracking bugs we have for this issue: https://github.com/haskell/cabal/issues/4120 Note that the data file directory can be overridden with environment variables, that might be good enough to work around.
It would be really nice if inplace data files worked. It is a little tricky to do, since the installed layout may not match the inplace layout, but maybe it would be OK if this were just opt in.
Thank you for the pointer to the ticket. I didn't find it myself because I did not expect that the problem has to do with Nix. :-)
I see that the problem is hard. Maybe paths relative to the executable could be another option?
participants (2)
-
Edward Z. Yang
-
Henning Thielemann