summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_NestedSplices.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/th/TH_NestedSplices.hs')
-rw-r--r--testsuite/tests/th/TH_NestedSplices.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/th/TH_NestedSplices.hs b/testsuite/tests/th/TH_NestedSplices.hs
new file mode 100644
index 0000000000..e16e6da8ff
--- /dev/null
+++ b/testsuite/tests/th/TH_NestedSplices.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE TemplateHaskell #-}
+module TH_NestedSplices where
+
+import Language.Haskell.TH
+
+import TH_NestedSplices_Lib
+-- This import brings in
+-- spliceExpr :: String -> Q Exp -> Q Exp
+-- declareFun :: String -> Q [Dec]
+
+-- Top level splice without $
+declareFun "a"
+
+-- Splice inside splice
+$(declareFun $(stringE "b"))
+
+-- Splice inside splice without outer $
+declareFun $(stringE "c")
+
+-- Ordinary splicing
+f x = $(spliceExpr "boo" [| x |])
+
+-- Splice inside splice
+g x = $(spliceExpr $(litE (stringL "boo")) [| x |])
+
+-- Ordinary splice inside bracket
+h1 = [| $(litE (integerL 3)) |]
+
+-- Splice inside splice inside bracket
+h2 = [| $(litE ($(varE 'integerL) 3)) |]
+