[commit: ghc] wip/merge: template-haskell: Missing instances for Rational and (). (fc3e8b3)
git at git.haskell.org
git at git.haskell.org
Wed Nov 19 04:27:56 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/merge
Link : http://ghc.haskell.org/trac/ghc/changeset/fc3e8b3ddb2eef1964e099e3518ca014ae5ff672/ghc
>---------------------------------------------------------------
commit fc3e8b3ddb2eef1964e099e3518ca014ae5ff672
Author: Mathieu Boespflug <m at tweag.io>
Date: Tue Nov 18 22:21:15 2014 -0600
template-haskell: Missing instances for Rational and ().
Test Plan: ./validate
Reviewers: austin
Reviewed By: austin
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D492
>---------------------------------------------------------------
fc3e8b3ddb2eef1964e099e3518ca014ae5ff672
docs/users_guide/7.10.1-notes.xml | 5 +++++
libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/docs/users_guide/7.10.1-notes.xml b/docs/users_guide/7.10.1-notes.xml
index 2e509e1..0cf3f61 100644
--- a/docs/users_guide/7.10.1-notes.xml
+++ b/docs/users_guide/7.10.1-notes.xml
@@ -176,6 +176,11 @@
Various features unsupported in quotations were previously
silently ignored. These now cause errors.
</para>
+
+ <para>
+ <literal>Lift</literal> instances were added for
+ <literal>()</literal> and <literal>Ratio</literal>.
+ </para>
</listitem>
</itemizedlist>
</sect3>
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 48199a4..6d4e5db 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -454,7 +454,10 @@ instance Lift Integer where
lift x = return (LitE (IntegerL x))
instance Lift Int where
- lift x= return (LitE (IntegerL (fromIntegral x)))
+ lift x = return (LitE (IntegerL (fromIntegral x)))
+
+instance Lift Rational where
+ lift x = return (LitE (RationalL x))
instance Lift Char where
lift x = return (LitE (CharL x))
@@ -478,6 +481,9 @@ liftString :: String -> Q Exp
-- Used in TcExpr to short-circuit the lifting for strings
liftString s = return (LitE (StringL s))
+instance Lift () where
+ lift () = liftM (ConE (tupleDataName 0))
+
instance (Lift a, Lift b) => Lift (a, b) where
lift (a, b)
= liftM TupE $ sequence [lift a, lift b]
More information about the ghc-commits
mailing list