summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Boespflug <m@tweag.io>2014-11-18 22:21:15 -0600
committerAustin Seipp <austin@well-typed.com>2014-11-19 17:03:05 -0600
commitb3df5f6b2562ffec4bb2fb486032903b8de5f475 (patch)
tree8629c864a59893a0888ff6ed7a104192e87cdc58
parent7ef0971a016d45915d1fa88a308db80a5c9e97ba (diff)
downloadhaskell-b3df5f6b2562ffec4bb2fb486032903b8de5f475.tar.gz
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
-rw-r--r--docs/users_guide/7.10.1-notes.xml5
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs11
2 files changed, 14 insertions, 2 deletions
diff --git a/docs/users_guide/7.10.1-notes.xml b/docs/users_guide/7.10.1-notes.xml
index 2e509e1e2d..0cf3f614a5 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 48199a4d8e..98130955b1 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP, DeriveDataTypeable, PolymorphicComponents,
- RoleAnnotations, DeriveGeneric #-}
+ RoleAnnotations, DeriveGeneric, TypeSynonymInstances,
+ FlexibleInstances #-}
-----------------------------------------------------------------------------
-- |
@@ -454,7 +455,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 +482,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 () = return (ConE (tupleDataName 0))
+
instance (Lift a, Lift b) => Lift (a, b) where
lift (a, b)
= liftM TupE $ sequence [lift a, lift b]