blob: da5e443605b1eca2148b0e6dbaf3fb6efe275cbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
{-# OPTIONS_GHC -XRecordWildCards -XNamedFieldPuns #-}
-- This is a very partial test of the record-wildcard extension
-- but better than nothing
module Main where
data T = C { x :: Int, y :: Int }
| D { x :: Int, b :: Bool }
select :: T -> Int
select = x
f :: (T,T) -> Int
f v = let (C {..}, d) = v in Main.x d
mkC a =
let x = a + 1
y = a * 2
in C{..}
sumC C{..} = x + y
foo x b =
let y = x+1
in (C{..}, let x = 100 in D{..})
bar a =
let (C{..}, d) = a
in (x + y + Main.x d, let D{..} = d in b)
main = do
print $ sumC $ mkC 10
print $ bar $ foo 5 True
|