Update Trac ticket URLs to point to GitLab
[ghc.git] / testsuite / tests / indexed-types / should_compile / Records.hs
1 {-# LANGUAGE TypeFamilies #-}
2
3 -- See #1204
4
5 module ShouldCompile where
6
7 data FooC = FooC
8
9 data family T c
10 data instance T FooC = MkT { moo :: Int }
11
12 t1 :: Int -> T FooC
13 t1 i = MkT { moo = i }
14
15 t2 :: T FooC -> Int
16 t2 (MkT { moo = i }) = i
17
18 t3 :: T FooC -> Int
19 t3 m = moo m
20
21 f :: T FooC -> T FooC
22 f r = r { moo = 3 }
23
24
25 ------------------------------------------------------------------------------
26 class D c where
27 data D1 c
28 works :: Int -> D1 c -> D1 c
29 buggy :: Int -> D1 c -> D1 c
30 buggy2 :: Int -> D1 c -> D1 c
31
32 instance D FooC where
33 data D1 FooC = D1F { noo :: Int }
34
35 works x d = d -- d unchanged, so OK
36
37 buggy x d@(D1F { noo = k }) =
38 d { noo = k + x }
39
40 buggy2 x d@(D1F { noo = k }) =
41 (d :: D1 FooC) { noo = k + x }