diff --git a/Generics/RepLib.hs b/Generics/RepLib.hs
--- a/Generics/RepLib.hs
+++ b/Generics/RepLib.hs
@@ -1,5 +1,5 @@
 -- OPTIONS -fglasgow-exts -fth -fallow-undecidable-instances
-{-# LANGUAGE TemplateHaskell, UndecidableInstances #-}
+{-# LANGUAGE TemplateHaskell, UndecidableInstances, CPP #-}
 
 -----------------------------------------------------------------------------
 -- |
@@ -37,7 +37,11 @@
  -- ** Derivable type classes written as generic operations
  module Generics.RepLib.PreludeLib,
 
+#if MIN_VERSION_base(4,7,0)
+ (:~:)(..), TestEquality(..)
+#else
  (:=:)(..), EqT(..)
+#endif
 ) where
 
 
diff --git a/Generics/RepLib/Derive.hs b/Generics/RepLib/Derive.hs
--- a/Generics/RepLib/Derive.hs
+++ b/Generics/RepLib/Derive.hs
@@ -83,7 +83,7 @@
 newtype QN a = QN { unQN :: WriterT (S.Set Int) Q a }
 #if MIN_VERSION_template_haskell(2,7,0)
   deriving (Applicative, Functor, Monad, MonadWriter (S.Set Int))
-#else    
+#else
   deriving (Functor, Monad, MonadWriter (S.Set Int))
 #endif
 
@@ -105,11 +105,20 @@
   qClassInstances n tys = liftQN $ qClassInstances n tys
 #endif
   qLocation             = liftQN qLocation
-  qRunIO io             = liftQN $ qRunIO io                       
+  qRunIO io             = liftQN $ qRunIO io
 #if MIN_VERSION_template_haskell(2,7,0)
   qLookupName ns s      = liftQN $ qLookupName ns s
   qAddDependentFile fp  = liftQN $ qAddDependentFile fp
 #endif
+#if MIN_VERSION_template_haskell(2,9,0)
+  qReifyRoles n         = liftQN $ qReifyRoles n
+  qReifyAnnotations al  = liftQN $ qReifyAnnotations al
+  qReifyModule m        = liftQN $ qReifyModule m
+  qAddTopDecls ds       = liftQN $ qAddTopDecls ds
+  qAddModFinalizer q    = liftQN $ qAddModFinalizer q
+  qGetQ                 = liftQN $ qGetQ
+  qPutQ a               = liftQN $ qPutQ a
+#endif
 
 -- Generate the representation for a data constructor.
 -- As our representation of data constructors evolves, so must this definition.
@@ -166,7 +175,11 @@
   let (con, args) = decomposeTy ty
   when (not (null args)) $ tell $ S.singleton (length args)
   liftQN $ case args of
+#if MIN_VERSION_base(4,7,0)
+    [] -> do e <- [| testEquality (rep :: R $(varT n)) $(return $ repty ty) |]
+#else
     [] -> do e <- [| eqT (rep :: R $(varT n)) $(return $ repty ty) |]
+#endif
              p <- [p| Just Refl |]
              return (e,p)
     _  -> do e <- [| $(varE (mkName $ "destr" ++ show (length args)))
@@ -174,7 +187,11 @@
                      (rep :: R $(appUnits con (length args)))
                   |]
              p <- conP (mkName $ "Result" ++ show (length args))
+#if MIN_VERSION_base(4,7,0)
+                       [sigP [p| Refl |] [t| $(varT n) :~: $(return ty) |] ]
+#else
                        [sigP [p| Refl |] [t| $(varT n) :=: $(return ty) |] ]
+#endif
              return (e,p)
 
 -- | Decompose a type into a constructor and a list of arguments.
@@ -617,8 +634,8 @@
 deriveRess = S.fold (liftM2 (++) . deriveResMaybe) (return [])
 
 deriveResMaybe :: Int -> Q [Dec]
-deriveResMaybe n = recover 
-                     (deriveRes n) 
+deriveResMaybe n = recover
+                     (deriveRes n)
                      (reify (mkName $ "Res" ++ show n) >> return [])
 
 deriveRes :: Int -> Q [Dec]
@@ -701,7 +718,7 @@
 
 -- (Data (DT s1 ((_ :: R b1') :+: (_ :: R b2') :+: MNil)) _)
 deriveResDestrLPat :: Name -> [Name] -> Pat
-deriveResDestrLPat s1 bs = 
+deriveResDestrLPat s1 bs =
   ConP 'Data
   [ ConP 'DT
     [ VarP s1
@@ -713,7 +730,7 @@
 
 -- (Data (DT s2 _) _)
 deriveResDestrRPat :: Name -> Pat
-deriveResDestrRPat s2 = 
+deriveResDestrRPat s2 =
   ConP 'Data
   [ ConP 'DT [ VarP s2, WildP ]
   , WildP
diff --git a/Generics/RepLib/Lib.hs b/Generics/RepLib/Lib.hs
--- a/Generics/RepLib/Lib.hs
+++ b/Generics/RepLib/Lib.hs
@@ -45,6 +45,9 @@
 import Generics.RepLib.PreludeReps()
 import Generics.RepLib.AbstractReps()
 
+import Control.Applicative (Applicative (..))
+import Control.Monad (ap,liftM)
+
 import Data.List (inits)
 
 import Data.Set (Set)
@@ -178,7 +181,7 @@
 
 instance (Rep k, Rep a) => Zero (Map k a) where
   zero = Map.empty
-  
+
 instance (Rep a) => Zero (Set a) where
   zero = Set.empty
 
@@ -225,7 +228,7 @@
 
 instance (Ord k, Generate k, Generate a) => Generate (Map k a) where
   generate 0 = []
-  generate i = map Map.fromList 
+  generate i = map Map.fromList
                  (inits [ (k, v) | k <- generate (i-1), v <- generate (i-1)])
 
 ------------ Enumerate -------------------------------
@@ -248,7 +251,7 @@
 enumerateR1 r1 = error ("No way to enumerate type: " ++ show r1)
 
 enumerateCons :: [Con EnumerateD a] -> [a]
-enumerateCons (Con emb rec:rest) = 
+enumerateCons (Con emb rec:rest) =
   (map (to emb) (fromTupM enumerateD rec)) ++ (enumerateCons rest)
 enumerateCons [] = []
 
@@ -268,7 +271,7 @@
 instance (Ord a, Enumerate a) => Enumerate (Set a) where
    enumerate = map Set.fromList enumerate
 instance (Ord k, Enumerate k, Enumerate a) => Enumerate (Map k a) where
-   enumerate = map Map.fromList 
+   enumerate = map Map.fromList
                  (inits [ (k, v) | k <- enumerate, v <- enumerate])
 
 ----------------- Shrink (from SYB III) -------------------------------
@@ -290,6 +293,13 @@
 
 data M a = M a [a]
 
+instance Functor M where
+  fmap = liftM
+
+instance Applicative M where
+  pure x = M x []
+  (<*>)  = ap
+
 instance Monad M where
  return x = M x []
  (M x xs) >>= k = M r (rs1 ++ rs2)
@@ -305,7 +315,7 @@
 
 instance (Ord a, Shrink a) => Shrink (Set a) where
   shrink x = map Set.fromList (shrink (Set.toList x))
-  
+
 instance (Ord k, Shrink k, Shrink a)  => Shrink (Map k a) where
   shrink m = map Map.fromList (shrink (Map.toList m))
 
diff --git a/Generics/RepLib/R.hs b/Generics/RepLib/R.hs
--- a/Generics/RepLib/R.hs
+++ b/Generics/RepLib/R.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE TemplateHaskell, UndecidableInstances, ExistentialQuantification,
     TypeOperators, GADTs, TypeSynonymInstances, FlexibleInstances,
-    ScopedTypeVariables
+    ScopedTypeVariables, CPP
  #-}
 -----------------------------------------------------------------------------
 -- |
@@ -32,7 +32,11 @@
    Arrow    :: (Rep a, Rep b) => R a -> R b -> R (a -> b)
    Data     :: DT -> [Con R a] -> R a
    Abstract :: DT -> R a
+#if MIN_VERSION_base(4,7,0)
+   Equal    :: (Rep a, Rep b) => R a -> R b -> R (a :~: b)
+#else
    Equal    :: (Rep a, Rep b) => R a -> R b -> R (a :=: b)
+#endif
 
 -- | Representation of a data constructor includes an
 -- embedding between the datatype and a list of other types
@@ -124,7 +128,11 @@
 instance Rep IOError where rep = IOError
 instance Rep a => Rep (IO a) where rep = IO rep
 instance (Rep a, Rep b) => Rep (a -> b) where rep = Arrow rep rep
+#if MIN_VERSION_base(4,7,0)
+instance (Rep a, Rep b) => Rep (a :~: b) where rep = Equal rep rep
+#else
 instance (Rep a, Rep b) => Rep (a :=: b) where rep = Equal rep rep
+#endif
 
 -- Unit
 
diff --git a/Generics/RepLib/R1.hs b/Generics/RepLib/R1.hs
--- a/Generics/RepLib/R1.hs
+++ b/Generics/RepLib/R1.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE 
+{-# LANGUAGE
              UndecidableInstances
            , GADTs
            , ScopedTypeVariables
@@ -6,6 +6,7 @@
            , FlexibleInstances
            , TypeSynonymInstances
            , TypeOperators
+           , CPP
  #-}
 {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
 
@@ -41,7 +42,12 @@
     Arrow1    :: (Rep a, Rep b) => ctx a -> ctx b -> R1 ctx (a -> b)
     Data1     :: DT -> [Con ctx a] -> R1 ctx a
     Abstract1 :: DT -> R1 ctx a
+#if MIN_VERSION_base(4,7,0)
+    Equal1    :: (Rep a, Rep b) => ctx a -> ctx b -> R1 ctx (a :~: b)
+#else
     Equal1    :: (Rep a, Rep b) => ctx a -> ctx b -> R1 ctx (a :=: b)
+#endif
+
 class Sat a where dict :: a
 
 class Rep a => Rep1 ctx a where rep1 :: R1 ctx a
@@ -98,7 +104,11 @@
          Rep1 ctx (a -> b) where rep1 = Arrow1 dict dict
 
 instance (Rep a, Rep b, Sat (ctx a), Sat (ctx b)) =>
+#if MIN_VERSION_base(4,7,0)
+         Rep1 ctx (a :~: b) where rep1 = Equal1 dict dict
+#else
          Rep1 ctx (a :=: b) where rep1 = Equal1 dict dict
+#endif
 
 -- Data structures
 
diff --git a/Generics/RepLib/RepAux.hs b/Generics/RepLib/RepAux.hs
--- a/Generics/RepLib/RepAux.hs
+++ b/Generics/RepLib/RepAux.hs
@@ -5,6 +5,7 @@
            , GADTs
            , Rank2Types
            , TypeOperators
+           , CPP
   #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
 -----------------------------------------------------------------------------
@@ -44,14 +45,25 @@
 import Generics.RepLib.R
 import Generics.RepLib.R1
 import GHC.Base (unsafeCoerce#)
+#if MIN_VERSION_base(4,7,0)
+import Data.Type.Equality (TestEquality(..), (:~:)(..))
+#else
 import Data.Type.Equality (EqT(..), (:=:)(..))
+#endif
 
 ------ Casting
 
+#if MIN_VERSION_base(4,7,0)
+instance TestEquality R where
+  -- testEquality :: R a -> R b -> Maybe (a :~: b)
+  testEquality ra rb =
+     if eqR ra rb then Just (unsafeCoerce# Refl) else Nothing
+#else
 instance EqT R where
   -- eqT :: R a -> R b -> Maybe (a :=: b)
   eqT ra rb =
      if eqR ra rb then Just (unsafeCoerce# Refl) else Nothing
+#endif
 
 -- | Determine if two reps are for the same type
 eqR :: R a -> R b -> Bool
@@ -83,7 +95,11 @@
 -- | The type-safe cast operation, explicit arguments
 castR :: R a -> R b -> a -> Maybe b
 castR ra rb a =
+#if MIN_VERSION_base(4,7,0)
+      case testEquality ra rb of
+#else
       case eqT ra rb of
+#endif
          Just Refl -> Just a
          Nothing   -> Nothing
 
@@ -94,7 +110,11 @@
 
 -- | Leibniz equality between types, explicit representations
 gcastR :: forall a b c. R a -> R b -> c a -> Maybe (c b)
+#if MIN_VERSION_base(4,7,0)
+gcastR ra rb x = case testEquality ra rb of
+#else
 gcastR ra rb x = case eqT ra rb of
+#endif
                     Just Refl -> Just x
                     Nothing   -> Nothing
 
diff --git a/RepLib.cabal b/RepLib.cabal
--- a/RepLib.cabal
+++ b/RepLib.cabal
@@ -1,5 +1,5 @@
 name:           RepLib
-version:        0.5.3.1
+version:        0.5.3.2
 license:        BSD3
 license-file:   LICENSE
 build-type:     Simple
@@ -7,7 +7,8 @@
 tested-with:    GHC == 7.0.4,
                 GHC == 7.2.1,
                 GHC == 7.4.1,
-                GHC == 7.6.1
+                GHC == 7.6.1,
+                GHC == 7.8.1
 author:         Stephanie Weirich
 maintainer:     Brent Yorgey <byorgey@cis.upenn.edu>
                 Chris Casinghino <ccasin@cis.upenn.edu>
@@ -25,10 +26,13 @@
 
 Library
   build-depends: base >= 4.3 && < 5,
-                 template-haskell >= 2.4 && < 2.9,
+                 template-haskell >= 2.4 && < 2.10,
                  mtl >= 2.0 && < 2.2,
-                 type-equality >= 0.1.0.2 && < 0.2,
                  containers >= 0.4 && < 0.6
+
+  if impl(ghc < 7.8)
+    build-depends: type-equality >= 0.1.0.2 && < 0.2
+
   exposed-modules:
     Generics.RepLib,
     Generics.RepLib.R,
@@ -48,7 +52,7 @@
                     OverlappingInstances
                     RankNTypes
                     ScopedTypeVariables
-                    ScopedTypeVariables 
+                    ScopedTypeVariables
                     TemplateHaskell
                     UndecidableInstances
   default-language: Haskell2010
