[project @ 1999-05-11 16:33:35 by keithw]
authorkeithw <unknown>
Tue, 11 May 1999 16:33:35 +0000 (16:33 +0000)
committerkeithw <unknown>
Tue, 11 May 1999 16:33:35 +0000 (16:33 +0000)
(this is number 3 of 9 commits to be applied together)

  Following Haskell 98, if the module declaration is omitted it now
  defaults to "module Main(main) where", rather than the previous
  default of exporting everything.

  Furthermore, "module Main where" also defaults to exporting just
  Main.main rather than everything in the module (modules other than
  Main behave as normal).  This permits the usage inference to give
  better results for the Main module, since exported functions get
  worse types than nonexported functions.

ghc/compiler/rename/RnNames.lhs

index db95e47..58dd7a6 100644 (file)
@@ -31,6 +31,7 @@ import RnMonad
 
 import FiniteMap
 import PrelMods
+import PrelInfo ( main_RDR )
 import UniqFM  ( lookupUFM )
 import Bag     ( bagToList )
 import Maybes  ( maybeToBool )
@@ -523,8 +524,13 @@ exportsFromAvail :: Module
         -- Warns about identical exports.
        -- Complains about exports items not in scope
 exportsFromAvail this_mod Nothing export_avails global_name_env
-  = exportsFromAvail this_mod (Just [IEModuleContents this_mod]) 
-                    export_avails global_name_env
+  = exportsFromAvail this_mod true_exports export_avails global_name_env
+  where
+    true_exports = Just $ if this_mod == mAIN
+                          then [IEVar main_RDR]
+                               -- export Main.main *only* unless otherwise specified,
+                          else [IEModuleContents this_mod]
+                               -- but for all other modules export everything.
 
 exportsFromAvail this_mod (Just export_items) 
                 (mod_avail_env, entity_avail_env)