aboutsummaryrefslogtreecommitdiff
path: root/hypsrc-test/src/TemplateHaskellQuasiquotes.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2020-03-20 20:17:01 -0400
committerAlec Theriault <alec.theriault@gmail.com>2020-03-20 20:17:01 -0400
commit053c9add568dad4264f4629bff0de9b10d9316e1 (patch)
tree0e6f4de693a1748fb59df1ef32e5596e6008af0b /hypsrc-test/src/TemplateHaskellQuasiquotes.hs
parent70f4b3a03a47b38ee301f0da9c72d5a7ff0ed9b0 (diff)
parentdae8d9de6aaf3913a3776f1af235fb72404e9970 (diff)
Merge branch 'ghc-8.8' into ghc-8.10
Diffstat (limited to 'hypsrc-test/src/TemplateHaskellQuasiquotes.hs')
-rw-r--r--hypsrc-test/src/TemplateHaskellQuasiquotes.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/hypsrc-test/src/TemplateHaskellQuasiquotes.hs b/hypsrc-test/src/TemplateHaskellQuasiquotes.hs
new file mode 100644
index 00000000..a1661895
--- /dev/null
+++ b/hypsrc-test/src/TemplateHaskellQuasiquotes.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module TemplateHaskellQuasiquotes where
+
+import Language.Haskell.TH
+
+aDecl :: DecsQ
+aDecl = [d|
+ bar :: $aType -> [ (Int, String) ]
+ bar $aPattern = $anExpression
+ |]
+
+aPattern :: PatQ
+aPattern = [p|
+ [ aCrazyLongVariableName
+ , _unused
+ , (y, z)
+ , ( $aNumberPattern, "hello")
+ ]
+ |]
+
+aNumberPattern :: PatQ
+aNumberPattern = [p|
+ w @ v @ 4.5
+ |]
+
+anExpression, anExpression2 :: ExpQ
+anExpression = [e|
+ [ (1 + $anExpression2, "world") ]
+ |]
+anExpression2 = [| (1 + round pi) |]
+
+aType :: TypeQ
+aType = [t|
+ [ (Double, String) ]
+ |]
+
+
+