summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Quote.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Quote.hs b/libraries/template-haskell/Language/Haskell/TH/Quote.hs
index 39cd2bace8..66ee115b61 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Quote.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Quote.hs
@@ -16,6 +16,7 @@ that is up to you.
module Language.Haskell.TH.Quote(
QuasiQuoter(..),
dataToQa, dataToExpQ, dataToPatQ,
+ liftData,
quoteFile
) where
@@ -88,14 +89,19 @@ dataToQa mkCon mkLit appCon antiQ t =
-- | 'dataToExpQ' converts a value to a 'Q Exp' representation of the
-- same value, in the SYB style. It is generalized to take a function
--- override type-specific cases; a useful default is 'const Nothing'
--- for no overriding.
+-- override type-specific cases; see 'liftData' for a more commonly
+-- used variant.
dataToExpQ :: Data a
=> (forall b . Data b => b -> Maybe (Q Exp))
-> a
-> Q Exp
dataToExpQ = dataToQa conE litE (foldl appE)
+-- | 'liftData' is a variant of 'lift' in the 'Lift' type class which
+-- works for any type with a 'Data' instance.
+liftData :: Data a => a -> Q Exp
+liftData = dataToExpQ (const Nothing)
+
-- | 'dataToPatQ' converts a value to a 'Q Pat' representation of the same
-- value, in the SYB style. It takes a function to handle type-specific cases,
-- alternatively, pass @const Nothing@ to get default behavior.