not naming modules Main

Max A . K . max630@mail.ru
Sat, 17 Nov 2001 03:50:16 +0600


Strange, I'm not annoyed by this at all though I supposed to
be. First I make module alone, and have 'module Main' and
'main' function there, then I use it in project, and change
the name to whichever I want and rename or delete the 'main'
function.

Anyway there can be a workaround (I didn't try it):

===== Module.hs
#ifdef Module_MAIN
module Main where
#else
module Module where
#endif

<..>

#ifdef Module_MAIN
main = test_main
#endif

<..>
===== end

===== Makefile
<..>
GHC_MAIN_MODULES=Module1 Module2
<..>
GHC_OPTS+=-cpp $(GHC_MAIN_MODULES:%=-D%_MAIN)
<..>
===== end

(that's GNU make, I don't know if this works in other. If
don't, just add the options -D<Modulename>_MAIN directly)

Then the only thing you have to change is the first
mentioned line in the Makefile.

Max.