diff --git a/Data/Generics/Alloy/GenInstances.hs b/Data/Generics/Alloy/GenInstances.hs
--- a/Data/Generics/Alloy/GenInstances.hs
+++ b/Data/Generics/Alloy/GenInstances.hs
@@ -1,5 +1,5 @@
 -- Alloy.
--- Copyright (c) 2008-2009, 2012 University of Kent.
+-- Copyright (c) 2008-2009, 2012, 2016 University of Kent.
 -- All rights reserved.
 -- 
 -- Redistribution and use in source and binary forms, with or without
@@ -67,23 +67,19 @@
    genVectorInstance,
    GenOverlappedOption(..), GenClassOption(GenOneClass), GenInstanceConfig(..)) where
 
-import Control.Monad.State
-import Data.Char
-import Data.Generics
-import Data.List
+import Control.Monad.State (StateT, execStateT, get, liftIO, liftM, modify, when)
+import Data.Char (isAlphaNum, ord)
+import Data.Generics (Data, Constr, Typeable, dataTypeConstrs, dataTypeOf, fromConstr, gmapQ, isAlgType)
+import Data.List (find, intersperse, nub, sort, sortBy)
 import Data.Map (Map)
 import qualified Data.Map as Map
-import Data.Ord
+import Data.Ord (comparing)
 import Data.Set (Set)
 import Data.Vector (Vector)
 import qualified Data.Set as Set
-import qualified Data.Typeable as Ty
+import Data.Typeable as Ty (Proxy(..), TyCon, TypeRep, splitTyConApp, tyConModule, typeRep)
 import qualified Data.Vector as Vector
 
-#if __GLASGOW_HASKELL__ < 702
-type TypeRepKey = Int
-#endif
-
 -- | The option controlling whether the generated instances can be overlapped.
 --  If you choose 'GenWithOverlapped' many less instances (around half, in our
 --  experience) will be generated, but you must enable the
@@ -163,8 +159,11 @@
 -- The Eq instance is based on the inner type.
 instance Eq Witness where
   (==) wx wy = case (witness wx, witness wy) of
-    (DataBox x, DataBox y) -> typeOf x == typeOf y
+    (DataBox x, DataBox y) -> typeRep (makeProxy x) == typeRep (makeProxy y)
 
+makeProxy :: t -> Proxy t
+makeProxy _ = Proxy
+
 funcPlain :: FuncType -> String
 funcPlain Func = ""
 funcPlain FuncM = "return"
@@ -714,13 +713,13 @@
 data DataBox = forall t. Data t => DataBox t
 
 instance Eq DataBox where
-  (==) (DataBox x) (DataBox y) = typeOf x == typeOf y
+  (==) (DataBox x) (DataBox y) = typeRep (makeProxy x) == typeRep (makeProxy y)
 
 type TypeMap = Map TypeRep (String, Witness)
 type TypeMapM = StateT TypeMap IO
 
 typeKey :: Typeable t => t -> IO TypeRep
-typeKey x = return $ typeOf x
+typeKey x = return $ typeRep (makeProxy x)
 
 toQualName :: Typeable t => t -> String
 toQualName w = fst (toQualNameMod w)
@@ -728,7 +727,7 @@
 -- First item is name of type, with everything inside qualified
 -- Second item is the module prefix (if any) of the outermost type
 toQualNameMod :: Typeable t => t -> (String, String)
-toQualNameMod w = toQualNameMod' (typeOf w)
+toQualNameMod w = toQualNameMod' (typeRep (makeProxy w))
 
 toQualNameMod' :: TypeRep -> (String, String)
 toQualNameMod' tr = case (show con, args) of
@@ -764,7 +763,7 @@
     doType :: Data t => t -> TypeMapM ()
     doType x
         =  do map <- get
-              key <- liftIO $ return $ typeOf rep
+              key <- liftIO $ return rep
               when (not $ key `Map.member` map) $
                  do modify $ Map.insert key (reps, Plain (DataBox x))
                     case custom $ DataBox x of
@@ -773,7 +772,7 @@
                         when (isAlgType dtype) $
                           mapM_ doConstr $ dataTypeConstrs dtype
       where
-        rep = typeOf x        
+        rep = typeRep (makeProxy x)        
         reps = show rep
         dtype = dataTypeOf x
 
diff --git a/alloy.cabal b/alloy.cabal
--- a/alloy.cabal
+++ b/alloy.cabal
@@ -1,5 +1,5 @@
 Name: alloy
-Version: 1.2.1
+Version: 1.2.2
 License: BSD3
 License-File: LICENSE
 Author: Neil Brown and Adam Sampson
@@ -30,7 +30,7 @@
                     tutorial/Selective.lhs
 
 Library
-  Build-Depends:   base >= 4.3 && < 5, containers, mtl, syb, vector
+  Build-Depends:   base >= 4.7 && < 5, containers, mtl, syb, vector
 
   Exposed-modules: Data.Generics.Alloy
                    Data.Generics.Alloy.Effect
