make option suggestion

Frederik Eaton frederik at
Mon Nov 6 16:12:21 EST 2006


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 If I edit, 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 If I use ghc, then I'll have to remember
to manually generate a new version of Source.hs every time I modify

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:

    $(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?



More information about the Glasgow-haskell-users mailing list