[project @ 1997-07-27 00:43:10 by sof]
[ghc-hetmet.git] / ghc / tests / programs / record_upd / Main.hs
1 {-      The purpose of this is to test that record update is
2         sufficiently polymorphic.  See comments with
3         tcExpr (RecordUpd) in TcExpr.lhs
4 -}
5
6 module Main where
7
8 data T a b c d  = MkT1 { op1 :: a, op2 :: b }
9                | MkT2 { op1 :: a, op3 :: c }
10                | MkT3 { op4 :: a, op5 :: d }
11
12 update1 :: a2 -> T a b c d -> T a2 b c d2
13 update1 x t = t { op1 = x }
14         -- NB: the MkT3.op4 case doesn't constrain the result because
15         -- it doesn't have an op1 field
16
17 update2 :: a2 -> T a b c d -> T a2 b2 c2 d
18 update2 x t = t { op4 = x }
19
20 main = print (op4 $ 
21               update2 True $ 
22               MkT3 { op4 = op2 $
23                            update1 (1::Int) $
24                            MkT1 { op1 = True }
25               })