not naming modules Main
Iavor S. Diatchki
Fri, 16 Nov 2001 11:49:30 -0800
the haskell report says that a program should contain
a module called "Main", which should export a function called "main"
of type IO().
there is no requiremnt however that the function "main" is defined
in the module "Main", it could for example be imported from somewhere.
so in your situation you could have a module "Main", which just imports
the module where the "main" function is defined (don't forget
to also export "main") and than you won't need to rename your module
all the time.
having said all that, there seems to be a bug in ghc (or perhaps
an implementation restriction), which requires that "main" is defined
in the module "Main". the only other haskell implementation i have
access to is hugs, and in this respect it behaves correctly, but alas
it has other issues with the module system.
On Fri, Nov 16, 2001 at 06:34:14PM +0000, Hal Daume wrote:
> I'm really frustrated that modules that you want to compile to
> executables have to be named Main. I often have a module with a main
> method that I use for testing or whatever (perhaps I want the gained
> speed of an executable) but is, for the most part, a module I import
> into others. I end up having to constantly change the module name
> whenever I want to compile it and I find this terribly frustrating.
> Is there any reason you can't just compile things that simply export a
> main method with the proper type? Is this a ghc specific thing or
> does nhc also have this restriction? Any chance ghc will change its
> policy on this?
> - Hal
> Hal Daume III
> "Computer science is no more about computers | email@example.com
> than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
> Haskell mailing list
| Iavor S. Diatchki, Ph.D. student |
| Department of Computer Science and Engineering |
| School of OGI at OHSU |
| http://www.cse.ogi.edu/~diatchki |