summaryrefslogtreecommitdiff
path: root/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/template-haskell/Language/Haskell/TH/Syntax.hs')
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 29be27a9a2..8879c62d19 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -1,6 +1,10 @@
{-# LANGUAGE CPP, DeriveDataTypeable, PolymorphicComponents,
RoleAnnotations, DeriveGeneric, FlexibleInstances #-}
+#if MIN_VERSION_base(4,8,0)
+#define HAS_NATURAL
+#endif
+
-----------------------------------------------------------------------------
-- |
-- Module : Language.Haskell.Syntax
@@ -29,16 +33,19 @@ import Data.Char ( isAlpha, isAlphaNum, isUpper )
import Data.Int
import Data.Word
import Data.Ratio
-import Numeric.Natural
import GHC.Generics ( Generic )
+#ifdef HAS_NATURAL
+import Numeric.Natural
+#endif
+
-----------------------------------------------------
--
-- The Quasi class
--
-----------------------------------------------------
-class Monad m => Quasi m where
+class (Applicative m, Monad m) => Quasi m where
qNewName :: String -> m Name
-- ^ Fresh names
@@ -487,8 +494,10 @@ instance Lift Word32 where
instance Lift Word64 where
lift x = return (LitE (IntegerL (fromIntegral x)))
+#ifdef HAS_NATURAL
instance Lift Natural where
lift x = return (LitE (IntegerL (fromIntegral x)))
+#endif
instance Integral a => Lift (Ratio a) where
lift x = return (LitE (RationalL (toRational x)))