From lemming at henning-thielemann.de Fri Mar 3 10:02:30 2017 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 3 Mar 2017 11:02:30 +0100 (CET) Subject: use data-files without installation Message-ID: 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? From ezyang at mit.edu Fri Mar 3 10:14:24 2017 From: ezyang at mit.edu (Edward Z. Yang) Date: Fri, 03 Mar 2017 02:14:24 -0800 Subject: use data-files without installation In-Reply-To: References: Message-ID: <1488535828-sup-2053@sabre> 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? From lemming at henning-thielemann.de Fri Mar 3 10:45:55 2017 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 3 Mar 2017 11:45:55 +0100 (CET) Subject: use data-files without installation In-Reply-To: <1488535828-sup-2053@sabre> References: <1488535828-sup-2053@sabre> Message-ID: 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? From ezyang at mit.edu Tue Mar 7 00:38:48 2017 From: ezyang at mit.edu (Edward Z. Yang) Date: Mon, 06 Mar 2017 16:38:48 -0800 Subject: use data-files without installation In-Reply-To: References: <1488535828-sup-2053@sabre> Message-ID: <1488847040-sup-6440@sabre> 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-Environment-Executable.html ). 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?