blob: dfd05187ba61f8603fbff48bfe0d5e31ff370597 (
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
35
36
37
38
39
40
41
42
43
44
45
46
|
-- test reification of data declarations
module TH_reifyDecl1 where
import Language.Haskell.TH
import Text.PrettyPrint.HughesPJ
infixl 3 `m`
-- simple
data T = A | B
-- parametric
data R a = C a | D
-- recursive
data List a = Nil | Cons a (List a)
-- infix operator
data Tree a = Leaf | Tree a :+: Tree a
-- type declaration
type IntList = [Int]
-- newtype declaration
newtype Length = Length Int
-- simple class
class C a where
m :: a -> Int
test :: ()
test = $(let
display :: Name -> Q ()
display q = do { i <- reify q; report False (pprint i) }
in do { display ''T
; display ''R
; display ''List
; display ''Tree
; display ''IntList
; display ''Length
; display 'Leaf
; display 'm
; [| () |] })
|