summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilAxelsson <>2020-10-17 16:28:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-10-17 16:28:00 (GMT)
commitb617816678b91860c99015ec20a0c17986059c8f (patch)
treeb598e46f4bc98337d013efa0e5bf5977fb899feb
parente21568bf5c2559c117f05a8630e11fdab5e5315d (diff)
version 0.1.4HEAD0.1.4master
-rw-r--r--haskell-exp-parser.cabal2
-rw-r--r--src/Language/Haskell/ParseExp.hs11
2 files changed, 11 insertions, 2 deletions
diff --git a/haskell-exp-parser.cabal b/haskell-exp-parser.cabal
index 66e783e..c7a8388 100644
--- a/haskell-exp-parser.cabal
+++ b/haskell-exp-parser.cabal
@@ -1,5 +1,5 @@
name: haskell-exp-parser
-version: 0.1.3
+version: 0.1.4
synopsis: Simple parser parser from Haskell to TemplateHaskell expressions
description: This package defines a simple parser for a subset of Haskell expressions and patterns to the TemplateHaskell AST.
.
diff --git a/src/Language/Haskell/ParseExp.hs b/src/Language/Haskell/ParseExp.hs
index 1a64408..f91770f 100644
--- a/src/Language/Haskell/ParseExp.hs
+++ b/src/Language/Haskell/ParseExp.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
-- | Simple parser for a subset of Haskell expressions and patterns to the
-- TemplateHaskell AST
--
@@ -26,6 +28,13 @@ import Text.ParserCombinators.ReadP
+mk_tupE :: [Exp] -> Exp
+#if MIN_VERSION_template_haskell(2,16,0)
+mk_tupE = TupE . map Just
+#else
+mk_tupE = TupE
+#endif
+
-- | Skip any amount of whitespace
skipSpace :: ReadP ()
skipSpace = void $ munch isSpace
@@ -89,7 +98,7 @@ tuple = do
case es of
[] -> return $ ConE $ mkName "()"
[e] -> return e
- _ -> return $ TupE es
+ _ -> return $ mk_tupE es
-- | Parse an expression that is not an application
expPart :: Bool -> ReadP Exp