summaryrefslogtreecommitdiff
path: root/ghc/lib/glaExts/MainIO13.lhs
blob: a650d095ef4e8b259bcae4e851e71c67723e4366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
This is the mainPrimIO13 that must be used for Haskell~1.3.

\begin{code}
module Main ( mainPrimIO13 ) where

import PreludeMain13_help	-- for type of "Main.main"
import Builtin			( error )
import PreludeIO
import UTypes			( Bin )

import Cls
import Core
import IChar
import IInt
import IList
import List		( (++) )
import Prel		( (.), not )
import PS		( _PackedString, _unpackPS )
import Text

mainPrimIO13 :: PrimIO ()

mainPrimIO13 s
  = case (main s) of { (result, s2@(S# _)) ->
    case result   of
      Right ()  -> ( (), s2 )
      Left  err -> error ("I/O error: "++shows err "\n")
    }
\end{code}

OLD COMMENT:

Nota Bene!  @mainIO@ is written as an explicit function, rather than
by saying: @mainIO = requestToIO main@ so that the code generator
recognises @mainIO@ as a {\em function} (hence HNF, hence not
updatable), rather than a zero-arity CAF (hence updatable).  If it is
updated, then we have a mega-space leak, because the entire action
(@requestToIO main@) is retained indefinitely.

(This doesn't waste work because @mainIO@ is only used once.)