
The {-# ORIGIN ... #-} keyword sounds like a nice solution, but wouldn't it require creating each generated file initially by hand, so that the compilers know that it exists? I'd rather have a build system where I can delete all of the generated files before distributing my code, and still have compilation work. Maybe I'm not understanding. Cheers, Frederik On Mon, Nov 06, 2006 at 09:37:18PM +0000, Neil Mitchell wrote:
Hi
Just for completeness, I came up with a proposal that would solve all this, but in a very non-cabal style way.
Taking an example of happy, every generated file (File.hs) would have as its first line:
{-# ORIGIN happy sourcefile.y -options -to -happy #-}
Then you just modify all haskell generating tools to output this (easy) and suddenly the whole problem of preprocessors goes away.
I realise its not the "cabal" style way of doing it - since the information gets put in the generated files etc - but it is pretty simple.
You can also add to the file Happy.y: {-# GENERATE happy sourcefile.y -options -to -happy #-}
To complete the other side of the generation.
Thanks
Neil
On 11/6/06, Duncan Coutts
wrote: I think this kind of build system feature ought to go into Cabal so it can be used more widely and without people needing Makefiles.
I admit that we're not there yet with how easy it is to generate source files.
Duncan
On Mon, 2006-11-06 at 21:12 +0000, Frederik Eaton wrote:
Hello,
I have a proposal for ghc. I think that it should take a new option, say "--make-command". This will specify a command to be run whenever a source file is read in by ghc. The command will be passed an argument, which is the name of the source file. The idea is that the command can be used to create auto-generated "source" files when ghc needs them.
The purpose of this would be the following. Suppose I have a source file, say Source.hs, which is generated from some template, say Source.hs.in. If I edit Source.hs.in, and compile my program with 'ghc --make', then the copy of Source.hs which ghc uses will be out of date. That's because ghc doesn't know about the fact that Source.hs is generated from Source.hs.in. If I use ghc, then I'll have to remember to manually generate a new version of Source.hs every time I modify Source.hs.in.
But under the present proposal, I would simply write a Makefile with the rules for generating Source.hs, and then pass --make-command=make to ghc. For instance, my Makefile might say:
Source.hs: Source.hs.in $(TAC) < $< > $@
Then every time I run ghc, and Source.hs is out of date, an up-to-date version of Source.hs will be generated automatically - because ghc will call 'make Source.hs' before reading it in.
Does this sound like a good idea?
Frederik
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users