Follow changes in comparison primops (see #6135)
[ghc.git] / testsuite / tests / codeGen / should_run / cgrun015.hs
1 {-# LANGUAGE MagicHash #-}
2 module Main ( main ) where
3
4 import Foreign
5 import Foreign.C
6 import GHC.Exts
7
8 data CList = CNil | CCons Int# CList
9
10 mk :: Int# -> CList
11 mk n = if isTrue# (n ==# 0#)
12 then CNil
13 else CCons 1# (mk (n -# 1#))
14
15 clen :: CList -> Int#
16 clen CNil = 0#
17 clen (CCons _ cl) = 1# +# (clen cl)
18
19 main = case (clen list4) of
20 len4 ->
21 case (len4 +# len4) of
22 8# -> finish 65# -- 'A'
23 _ -> finish 66# -- 'B'
24 where
25 list4 = mk 4#
26
27 finish :: Int# -> IO ()
28 finish n = c_putchar (castCharToCChar (C# (chr# n))) >> return ()
29
30 foreign import ccall unsafe "putchar"
31 c_putchar :: CChar -> IO CInt