[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / lib / glaExts / MainIO13.lhs
1 This is the mainPrimIO13 that must be used for Haskell~1.3.
2
3 \begin{code}
4 module Main ( mainPrimIO13 ) where
5
6 import PreludeMain13_help       -- for type of "Main.main"
7 import Builtin                  ( error )
8 import PreludeIO
9 import UTypes                   ( Bin )
10
11 import Cls
12 import Core
13 import IChar
14 import IInt
15 import IList
16 import List             ( (++) )
17 import Prel             ( (.), not )
18 import PS               ( _PackedString, _unpackPS )
19 import Text
20
21 mainPrimIO13 :: PrimIO ()
22
23 mainPrimIO13 s
24   = case (main s) of { (result, s2@(S# _)) ->
25     case result   of
26       Right ()  -> ( (), s2 )
27       Left  err -> error ("I/O error: "++shows err "\n")
28     }
29 \end{code}
30
31 OLD COMMENT:
32
33 Nota Bene!  @mainIO@ is written as an explicit function, rather than
34 by saying: @mainIO = requestToIO main@ so that the code generator
35 recognises @mainIO@ as a {\em function} (hence HNF, hence not
36 updatable), rather than a zero-arity CAF (hence updatable).  If it is
37 updated, then we have a mega-space leak, because the entire action
38 (@requestToIO main@) is retained indefinitely.
39
40 (This doesn't waste work because @mainIO@ is only used once.)