Main.main naming convention
Iavor S. Diatchki
diatchki@cse.ogi.edu
Wed, 11 Sep 2002 08:30:40 -0700
hi,
koen wrote:
> ...
> Another such restriction is the fact that any module which
> is called Main *must* have a function which is called main
> in it.
> ...
technically a module called Main need not define a function called main.
all that is required is that there is a function called main in scope.
if there isn't one ghci gives a warning these days, wihch seems quite
reasonable.
martin wrote:
> ...
> You'd need to specify which module should be the top-level module when
> compiling, of course.
> ...
by the way, you can get what you want in GHC i think by the follwoing
trick (it is a trick however):
#ifndef MAIN_IS_A
module A
#endif
main = print "A"
now you can compile it as follows, to get an executable:
ghc -cpp -D=MAIN_IS_A A.hs
if you want to use it as a library, just omit the -D part.
also if you will be doing this a lot it may be a good idea to use the
-odir -hidir flgas of GHC.
bye
iavor
--
==================================================
| Iavor S. Diatchki, Ph.D. student |
| Department of Computer Science and Engineering |
| School of OGI at OHSU |
| http://www.cse.ogi.edu/~diatchki |
==================================================