
Hi. Currently when Cabal preprocesses a module the result ends up in the source directory. I would have expected it to end up in dist, since it's a generated file and not a source file. So, - are there strong reasons for putting preprocessed files in src? - if not, is there a simple (and robust) way to have them end up in dist? / Ulf

Ulf,
- are there strong reasons for putting preprocessed files in src?
One reason could be that, when distributing *sources*, you'd want the generated file to be included as well (that is, you want to regard it as a source file), for the system your program is to be compiled on might not have the preprocessor available and you don't want to make that a hard requirement... Of course, you can still achieve this by putting it in dist and put the file from dist in the generated tarball, but, arguably, the way it's done now, makes explicit that the file might be viewed as a source file. Also, building executables with GHC --make requires (?) modules to be present in designated locations in the directory tree... Just some thoughts, though... Cheers, Stefan

On Nov 29, 2006, at 10:21 PM, Stefan Holdermans wrote:
- are there strong reasons for putting preprocessed files in src?
One reason could be that, when distributing *sources*, you'd want the generated file to be included as well (that is, you want to regard it as a source file), for the system your program is to be compiled on might not have the preprocessor available and you don't want to make that a hard requirement... Of course, you can still achieve this by putting it in dist and put the file from dist in the generated tarball, but, arguably, the way it's done now, makes explicit that the file might be viewed as a source file.
The problem with that is that someone getting the sources might get the idea that the preprocessed file is an actual source file and try to modify it (or just make sense of it, imagine someone trying to read a happy parser...). Including parts of dist in the tarball makes it clear that what you get is not a vanilla source distribution.
Also, building executables with GHC --make requires (?) modules to be present in designated locations in the directory tree...
You just have to run GHC with -idist/... This is the way I had it set up before migrating to Cabal. / Ulf

Ulf Norell wrote:
Stefan Holdermans wrote:
One reason could be that, when distributing *sources*, you'd want the generated file to be included as well (that is, you want to regard it as a source file),
The problem with that is that someone getting the sources might get the idea that the preprocessed file is an actual source file and try to modify it (or just make sense of it, imagine someone trying to read a happy parser...).
True (although I'm not sure how much of a problem that really is). However, if one is relying on some "exotic" preprocessing, it can be really helpful for people who are just interested in getting the code up and running if they don't have to install a bunch of preprocessors first. As a case in point, (a long time ago) we distributed Frob (Robot programming layer on top of FRP) both with Greencard sources and the output from Greencard for that very reason. But maybe this is less of an issue with Cabal taking a lot of pain out of building and installing?
Including parts of dist in the tarball makes it clear that what you get is not a vanilla source distribution.
Yes, that's possibly a better way of doing it. As long as there is a way of generating preprocessed pure Haskell for distribution. Best, /Henrik -- Henrik Nilsson School of Computer Science and Information Technology The University of Nottingham nhn@cs.nott.ac.uk This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

On Nov 30, 2006, at 11:13 AM, Henrik Nilsson wrote:
The problem with that is that someone getting the sources might get the idea that the preprocessed file is an actual source file and try to modify it (or just make sense of it, imagine someone trying to read a happy parser...).
True (although I'm not sure how much of a problem that really is).
You'd be surprised :) I've been teaching a course in programming language implementation where I have had to stop several students from "fixing" generated code. / Ulf

Ulf,
The problem with that is that someone getting the sources might get the idea that the preprocessed file is an actual source file and try to modify it (or just make sense of it, imagine someone trying to read a happy parser...). Including parts of dist in the tarball makes it clear that what you get is not a vanilla source distribution.
Point taken. But ;), still, for instance, the Haskell files generated by our attribute grammar system all start with -- do not edit; automatically generated by UU.AG Anyway, I'm not the best pick for defending the way it's done right now: I can perfectly live with either of these two alternatives, I guess. Cheers, Stefan
participants (3)
-
Henrik Nilsson
-
Stefan Holdermans
-
Ulf Norell