Add Fixity info for infix types
[ghc.git] / testsuite / tests / th / TH_reifyDecl1.hs
1 -- test reification of data declarations
2
3 {-# LANGUAGE TypeFamilies #-}
4 module TH_reifyDecl1 where
5
6 import System.IO
7 import Language.Haskell.TH
8 import Text.PrettyPrint.HughesPJ
9
10 infixl 3 `m1`
11
12 -- simple
13 data T = A | B
14
15 -- parametric
16 data R a = C a | D
17
18 -- recursive
19 data List a = Nil | Cons a (List a)
20
21 -- infix operator
22 data Tree a = Leaf | Tree a :+: Tree a
23
24 -- type declaration
25 type IntList = [Int]
26
27 -- newtype declaration
28 newtype Length = Length Int
29
30 -- simple class
31 class C1 a where
32 m1 :: a -> Int
33
34 -- class with instances
35 class C2 a where
36 m2 :: a -> Int
37 instance C2 Int where
38 m2 x = x
39
40 -- associated types
41 class C3 a where
42 type AT1 a
43 data AT2 a
44
45 instance C3 Int where
46 type AT1 Int = Bool
47 data AT2 Int = AT2Int
48
49 -- type family
50 type family TF1 a
51
52 -- type family, with instances
53 type family TF2 a
54 type instance TF2 Bool = Bool
55
56 -- data family
57 data family DF1 a
58
59 -- data family, with instances
60 data family DF2 a
61 data instance DF2 Bool = DBool
62
63 $(return [])
64
65 test :: ()
66 test = $(let
67 display :: Name -> Q ()
68 display q = do { i <- reify q; runIO $ hPutStrLn stderr (pprint i) }
69 in do { display ''T
70 ; display ''R
71 ; display ''List
72 ; display ''Tree
73 ; display ''IntList
74 ; display ''Length
75 ; display 'Leaf
76 ; display 'm1
77 ; display ''C1
78 ; display ''C2
79 ; display ''C3
80 ; display ''AT1
81 ; display ''AT2
82 ; display ''TF1
83 ; display ''TF2
84 ; display ''DF1
85 ; display ''DF2
86 ; [| () |] })
87
88