[project @ 1999-01-23 18:10:00 by sof]
[ghc-hetmet.git] / ghc / tests / codeGen / should_run / cg031.hs
1 -- !! test GEN reps w/ unboxed values in them
2 -- !! NB: it was the static ones that were hosed...
3 --
4 module Main ( main ) where
5
6 import PrelBase
7
8 main = do
9     putStr (shows (sum ([1..1{-30-}]++[1..1{-40-}]++[11,22])) "\n")
10     putStr (shows (prog 1{-30-} 1{-40-}) "\n")
11
12 data Foo a
13   = MkFoo [a] Int# [Int] Int# [(a,Int)] Int#
14   -- The above will cause a *horrible* GEN rep'n.
15
16 prog :: Int -> Int -> Int
17
18 prog size_1 size_2
19   = let
20         list1 = static1 : (map mk_foo [1 .. size_1])
21         list2 = static2 : (map mk_foo [1 .. size_2])
22     in
23     I# (add_up 0# list1 (reverse list2))
24
25 static1 = MkFoo (error "static11") 11# [] 11# (error "static12") 11#
26 static2 = MkFoo (error "static21") 22# [] 22# (error "static22") 22#
27
28 one, two :: Int
29 one = 1; two = 2
30
31 mk_foo i@(I# i#)
32   = MkFoo (error "list1") i# [i,i] i# (error "list2") i#
33
34 add_up :: Int# -> [Foo a] -> [Foo a] -> Int#
35
36 add_up acc [] [] = acc
37 add_up acc [] ys  = add_up acc ys []
38 add_up acc (x:xs) (y:ys) = add_up (acc +# add x y) xs ys
39 add_up acc (x:xs) [] = add_up acc xs []
40
41 add :: Foo a -> Foo a -> Int#
42 add (MkFoo _ _ _ _ _ x) (MkFoo _ _ _ _ _ y)
43   = x +# y