1 module ShouldCompile where
3 -- Strict field unpacking tests: compile with -O -funbox-strict-fields.
5 -- test 1: simple unboxed int field
9 -- test 2: mutual recursion (should back off from unboxing either field)
15 -- test 3: multi-level unboxing
20 g (A x (B y) z) = A x (B (y+2)) z
21 h (A x (B y) z) = y + 2
23 -- test 4: flattening nested tuples
27 -- test 5: polymorphism, multiple strict fields
28 data D a b = D Int !(a,b) !(E Int)
30 k (D a (b,c) (E d)) = a + b + c + d
33 data F a b = F { x :: !Int, y :: !(Float,Float), z :: !(a,b) }
39 newtype G a b = G (F a b)
40 data H a b = H !Int !(G a b) !Int
41 o (H y (G (F{ x=x })) z) = x + z