special handling of "Main.hs" contradicts Report
Dean Herington
heringto at cs.unc.edu
Fri Apr 25 10:06:27 EDT 2003
Ross Paterson wrote:
> On Fri, Apr 25, 2003 at 09:51:55AM +0100, Simon Marlow wrote:
> > [Mark Tullsen <mtullsen at cse.ogi.edu> writes:]
> > > The report leads one to believe "module Main where ..."
> > > should export
> > > all top-level entitities just the same as if we were
> > > defining a module by another name.
> >
> > Yes, we're aware this is a bug (see my first message in this thread).
> > However, I think we're going to declare it as a known
> > divergence from the report, for two reasons:
> >
> > - It's highly unlikely that you need to import Main, so
> > you'll never notice the difference. If you *do* need more
> > exports from Main, then write 'module Main(module Main) where'.
>
> I expect it would be confusing for GHCi users.
>
> > - interpreting 'module Main where' as 'module Main(main) where'
> > leads to more efficient code (we have lots of examples
> > that do this, I believe).
>
> How about just suggesting that users write 'module Main(main) where'
> to get more efficient code?
I second Ross's opinions. Here's a situation that I just encountered that
argues for his approach.
I'm developing a program. I usually compile it (using `ghc`) after making
changes, so I can run some batch tests. Sometimes I want to do some
interactive exploration, in which case I invoke `ghci` on it. Without the
artificial `module Main (module Main) where`, ghci sees none of the
top-level entities in the main module in its compiled form. I have to
artificially change the source file and :reload to see these entities.
Dean
More information about the Glasgow-haskell-bugs
mailing list