[project @ 1996-06-27 16:55:06 by partain]
[ghc-hetmet.git] / ghc / lib / prelude / GHCmain.hs
1 -- This is the mainPrimIO that must be used for Haskell~1.3.
2
3 module GHCmain ( mainPrimIO ) where
4
5 import qualified Main   -- for type of "Main.main"
6 import GHCbase
7
8 mainPrimIO :: PrimIO ()
9
10 mainPrimIO = ST $ \ s ->
11     case Main.main   of { IO (ST main_guts) ->
12     case main_guts s of { (result, s2@(S# _)) ->
13     case result   of
14       Right ()  -> ( (), s2 )
15       Left  err -> error ("I/O error: "++showsPrec 0 err "\n")
16     }}
17
18 {-
19 OLD COMMENT:
20
21 Nota Bene!  @mainIO@ is written as an explicit function, rather than
22 by saying: @mainIO = requestToIO main@ so that the code generator
23 recognises @mainIO@ as a {\em function} (hence HNF, hence not
24 updatable), rather than a zero-arity CAF (hence updatable).  If it is
25 updated, then we have a mega-space leak, because the entire action
26 (@requestToIO main@) is retained indefinitely.
27
28 (This doesn't waste work because @mainIO@ is only used once.)
29 -}