not naming modules Main

Simon Marlow simonmar@microsoft.com
Tue, 20 Nov 2001 09:52:11 -0000


> Coming up with proposals is always much more difficult that simply
> complaining about something.  Here is a proposal which seems
> reasonable to me (and implementable):
>=20
>      Allow any module to have a main function.  When you compile (with
>      ghc), and you say, for example:
>       % ghc --make Foo.hs -o Foo
>      then it looks in Foo.hs for the main function (regardless of
>      whether the name of the module appearing in Foo.hs is Main or
>      Foo).  As I never use ghc without the --make option, I'm not sure
>      how this would roll over when not using it.  Perhaps there could
>      be an option like:
>       % ghc Foo.hs Bar.hs FooBar.hs -o Foo -main-in Foo.hs
>      or something where you can specify which module has the main you
>      want to use.
>=20
>      Then, say you have two modules, Foo.hs (containing module Foo)
>      and Bar.hs (containing module Bar), both with main functions,
>      suppose Foo is the one from which the desire main function comes,
>      you can always "import Bar hiding (main)".

While we could do doubt implement this, I'm not sure the benefits are
compelling enough.  As Simon points out, you can always do your testing
in GHCi which doesn't care whether you have a Main module or not.
Furthermore this would be an extension to Haskell which isn't supported
by the other compilers, so its usefulness is limited.

Would anyone else find this useful?

Cheers,
	Simon