Testsuite: tabs -> spaces [skip ci]
[ghc.git] / testsuite / tests / gadt / ubx-records.hs
1 {-# LANGUAGE GADTs #-}
2 {-# OPTIONS_GHC -funbox-strict-fields #-}
3
4 -- Tests record selectors with unboxed fields for GADTs
5
6 module Main where
7
8 data T a where
9 T1 :: { w :: !(Int, Int), x :: a, y :: b } -> T (a,b)
10 T2 :: { w :: !(Int, Int), x :: a } -> T (a,b)
11 T3 :: { z :: Int } -> T Bool
12
13 -- T1 :: forall c a b. (c~(a,b)) => (Int,Int) -> a -> b -> T c
14
15 f xv yv = T1 { w = (0,0), x = xv, y = yv }
16
17 g :: T a -> T a
18 g (T1 {x=xv, y=yv}) = T2 { w = (0,0), x = xv }
19
20 -- h :: Num a => T a any -> a
21 h v = x v + 1
22
23 i v = let (x,y) = w v in x + y
24
25 main = do { let t1 = T1 { w = (0,0), y = "foo", x = 4 }
26 t2 = g t1
27 ; print (h (f 8 undefined))
28 ; print (h t2)
29 ; print (i t1)
30 }