b3d8568a14b8fb8076009651d15b81720ac63398
[ghc.git] / testsuite / tests / deSugar / should_compile / ds035.hs
1 {-# LANGUAGE MagicHash, BangPatterns #-}
2 module ShouldCompile where
3
4 import GHC.Exts
5
6 data CList = CNil | CCons Int# CList
7
8 mk :: Int# -> CList
9 mk n = case (n ==# 0#) of
10 False -> CNil
11 _ -> CCons 1# (mk (n -# 1#))
12
13 clen :: CList -> Int#
14 clen CNil = 0#
15 clen (CCons _ cl) = 1# +# (clen cl)
16
17 main = putStr (case len4_twice of
18 8# -> "bingo\n"
19 _ -> "oops\n")
20 where
21 list4 = mk 4#
22 !len4 = clen list4
23 !len4_twice = len4 +# len4