Main.main naming convention

John Meacham john@repetae.net
Tue, 10 Sep 2002 00:54:51 -0700


I always thought it would be nice to just have a compiler option
'--main Bar.Foo.testFoo' which would just the specified function (assuming
it is of the appropriate type) as main. if you leave off the function
name, then it is assumed to be main. It would be nice if it worked
whether or not the function name was exported, as that would mean when
you do not use it as the main, dead-code elimination could dispose of
it, although i could see how this might be problematic if you dont want
to recompile depending on what --main is set too.
Allowing you to specify the function name as well as the module name is
important if you dont want lots of functions named main conflicting with
each other.
	John


On Tue, Sep 10, 2002 at 09:29:30AM +0200, Martin Norbäck wrote:
> tis 2002-09-10 klockan 01.22 skrev Manuel M T Chakravarty:
> > Martin Norbäck <d95mback@dtek.chalmers.se> wrote,
> > 
> > > I have a question about the Main.main naming convention. Would it be a
> > > good idea to lift the restriction and allow any module which exports a
> > > function main :: IO () to be compiled into a separate binary?
> > > 
> > > You'd need to specify which module should be the top-level module when
> > > compiling, of course.
> > > 
> > > Why I'm asking is because I have several Main modules in one directory,
> > > in files like Program1.hs, Program2.hs and so on, but all of these
> > > claims (and must claim) to be "module Main".
> > 
> > So?  That just means that the file name of Program1.hs,
> > Program2.hs, etc will be different from the name of the
> > module that they contain.  I think all Haskell systems allow
> > the Main module to be in a file whose name differs from the
> > module name (in contrast to other modules, which need to be
> > found when chasing imports).
> 
> Well, one reason is that I may very well want to import the module
> containing main into another module. Another reason is that hdoc will
> use the name in the module statement instead of the file name, and
> rightly so, how is it to know what the module name should be, especially
> if the module is in a directory in a hirarchical module space.
> 
> It's not a big thing, but I just wonder if there is a reason not to
> allow any module containg main to be compiled into a program.
> 
> Regards,
> 
> 	Martin
> 



-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john@foo.net
---------------------------------------------------------------------------