[project @ 1999-07-14 12:31:14 by simonmar]
[ghc-hetmet.git] / ghc / tests / deSugar / should_compile / ds046.hs
1 module Test where
2
3 -- Strict field unpacking tests: compile with -O -funbox-strict-fields.
4
5 -- test 1: simple unboxed int field
6 data T = T !Int
7 t (T i) = i + 1
8
9 -- test 2: mutual recursion (should back off from unboxing either field)
10 data R = R !R
11 data S = S !S
12
13 r (R s) = s
14
15 -- test 3: multi-level unboxing
16 data A = A Int !B Int
17 data B = B !Int
18
19 f = A 1 (B 2) 1
20 g (A x (B y) z) = A x (B (y+2)) z
21 h (A x (B y) z) = y + 2
22
23 -- test 4: flattening nested tuples
24 data C = C !(Int,Int)
25 j (C (a,b)) = a + b
26
27 -- test 5: polymorphism, multiple strict fields
28 data D a b = D Int !(a,b) !(E Int)
29 data E a = E a
30 k (D a (b,c) (E d)) = a + b + c + d