Fix #11287.
[ghc.git] / testsuite / tests / th / TH_NestedSplices.hs
1 {-# LANGUAGE TemplateHaskell #-}
2 module TH_NestedSplices where
3
4 import Language.Haskell.TH
5
6 import TH_NestedSplices_Lib
7 -- This import brings in
8 -- spliceExpr :: String -> Q Exp -> Q Exp
9 -- declareFun :: String -> Q [Dec]
10
11 -- Top level splice without $
12 declareFun "a"
13
14 -- Splice inside splice
15 $(declareFun $(stringE "b"))
16
17 -- Splice inside splice without outer $
18 declareFun $(stringE "c")
19
20 -- Ordinary splicing
21 f x = $(spliceExpr "boo" [| x |])
22
23 -- Splice inside splice
24 g x = $(spliceExpr $(litE (stringL "boo")) [| x |])
25
26 -- Ordinary splice inside bracket
27 h1 = [| $(litE (integerL 3)) |]
28
29 -- Splice inside splice inside bracket
30 h2 = [| $(litE ($(varE 'integerL) 3)) |]
31