[project @ 1996-01-18 16:33:17 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 import TyComplex
21 import TyArray
22
23 mainPrimIO13 :: PrimIO ()
24
25 mainPrimIO13 s
26   = case (main s) of { (result, s2@(S# _)) ->
27     case result   of
28       Right ()  -> ( (), s2 )
29       Left  err -> error ("I/O error: "++showsPrec 0 err "\n")
30     }
31 \end{code}
32
33 OLD COMMENT:
34
35 Nota Bene!  @mainIO@ is written as an explicit function, rather than
36 by saying: @mainIO = requestToIO main@ so that the code generator
37 recognises @mainIO@ as a {\em function} (hence HNF, hence not
38 updatable), rather than a zero-arity CAF (hence updatable).  If it is
39 updated, then we have a mega-space leak, because the entire action
40 (@requestToIO main@) is retained indefinitely.
41
42 (This doesn't waste work because @mainIO@ is only used once.)