[project @ 2002-02-05 15:42:04 by simonpj]
authorsimonpj <unknown>
Tue, 5 Feb 2002 15:42:11 +0000 (15:42 +0000)
committersimonpj <unknown>
Tue, 5 Feb 2002 15:42:11 +0000 (15:42 +0000)
commite66018084e22615311828b7a221d5df25cdf09ea
tree6cc4caa59219ae0b2397c7d2114379448d641d02
parentfcd0dea6bcbe44f992e2a643ae3261e44df17961
[project @ 2002-02-05 15:42:04 by simonpj]
---------
Main.main
---------

A bunch of related fixes concerning 'main'

* Arrange that 'main' doesn't need to be defined in module Main;
  it can be imported.

* The typechecker now injects a binding
Main.$main = PrelTopHandler.runMain main

  So the runtime system now calls Main.$main, not PrelMain.main.
  With z-encoding, this look like
Main_zdmain_closure

* The function
   PrelTopHandler.runMain :: IO a -> IO ()
  wraps the programmer's 'main' in an exception-cacthing wrapper.

* PrelMain.hs and Main.hi-boot are both removed from lib/std, along
  with multiple lines of special case handling in lib/std/Makefile.
  This is a worthwhile cleanup.

* Since we now pick up whatever 'main' is in scope, the ranamer gets
  in on the act (RnRnv.checkMain).  There is a little more info to
  get from the renamer to the typechecker, so I've defined a new type
  Rename.RnResult (c.f. TcModule.TcResult)

* With GHCi, it's now a warning, not an error, to omit the binding
  of main (RnEnv.checkMain)

* It would be easy to add a flag "-main-is foo"; the place to use
  that information is in RnEnv.checkMain.

-------

On the way I made a new type,
type HscTypes.FixityEnv = NameEnv Fixity
and used it in various places I'd tripped over
23 files changed:
ghc/compiler/main/DriverPipeline.hs
ghc/compiler/main/HscMain.lhs
ghc/compiler/main/HscTypes.lhs
ghc/compiler/main/MkIface.lhs
ghc/compiler/prelude/PrelNames.lhs
ghc/compiler/rename/Rename.lhs
ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnHiFiles.lhs
ghc/compiler/rename/RnHsSyn.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/rename/RnSource.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcDeriv.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcGenDeriv.lhs
ghc/compiler/typecheck/TcInstDcls.lhs
ghc/compiler/typecheck/TcModule.lhs
ghc/lib/std/Main.hi-boot [deleted file]
ghc/lib/std/Makefile
ghc/lib/std/PrelMain.lhs [deleted file]
ghc/lib/std/PrelTopHandler.hs
ghc/rts/Main.c
ghc/rts/Prelude.h