[project @ 1997-09-05 14:11:05 by simonm]
[ghc-hetmet.git] / ghc / tests / codeGen / should_run / cg015.hs
1 module GHCmain ( mainPrimIO ) where
2
3 import GlaExts
4 import PrelBase
5
6 data CList = CNil | CCons Int# CList
7
8 mk :: Int# -> CList
9 mk n  = if (n ==# 0#)
10         then CNil
11         else CCons 1# (mk (n -# 1#))
12
13 clen :: CList -> Int#
14 clen CNil = 0#
15 clen (CCons _ cl) = 1# +# (clen cl)
16
17 mainPrimIO = case (clen list4) of
18                 len4 ->
19                   case (len4 +# len4) of
20                     8# -> finish 65#    -- 'A'
21                     _  -> finish 66#    -- 'B'
22       where
23       list4     = mk 4#
24
25 finish :: Int# -> PrimIO ()
26 finish n = _ccall_ putchar (C# (chr# n)) `seqPrimIO` returnPrimIO ()