diff --git a/Data/TrieMap/MultiRec/Ord.hs b/Data/TrieMap/MultiRec/Ord.hs
--- a/Data/TrieMap/MultiRec/Ord.hs
+++ b/Data/TrieMap/MultiRec/Ord.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE FlexibleInstances, TypeOperators, MultiParamTypeClasses, Rank2Types #-}
+{-# LANGUAGE FlexibleInstances, TypeOperators, MultiParamTypeClasses, Rank2Types, GADTs #-}
 
 module Data.TrieMap.MultiRec.Ord where
 
diff --git a/Data/TrieMap/Regular/TH.hs b/Data/TrieMap/Regular/TH.hs
--- a/Data/TrieMap/Regular/TH.hs
+++ b/Data/TrieMap/Regular/TH.hs
@@ -9,34 +9,13 @@
 deriveM :: Q [Dec] -> Q [Dec]
 deriveM decs = do
 	iT@(InstanceD cxt inst _:_) <- decs
-	(InstanceD _ _ myDecs:_) <- [d|
-	  instance (TrieKeyT f m, Ord (f k), TrieKey k mm) => TrieKey (f k) (m k) where
-		emptyM = emptyT
-		nullM = nullT
-		lookupM = lookupT
-		lookupIxM = lookupIxT
-		assocAtM = assocAtT
--- 		updateAtM = updateAtT
-
-		alterM = alterT
-		alterLookupM = alterLookupT
-		traverseWithKeyM = traverseWithKeyT
-		foldWithKeyM = foldWithKeyT
-		foldlWithKeyM = foldlWithKeyT
-		mapEitherM = mapEitherT
-		splitLookupM = splitLookupT
-		unionM = unionT
-		isectM = isectT
-		diffM = diffT
-		extractM = extractT
--- 		extractMinM = extractMinT
--- 		extractMaxM = extractMaxT
--- 		alterMinM = alterMinT
--- 		alterMaxM = alterMaxT
-		isSubmapM = isSubmapT
-		fromListM = fromListT
-		fromAscListM = fromAscListT
-		fromDistAscListM = fromDistAscListT |]
+	let myDecs = zipWith (\ m t -> ValD (VarP m) (NormalB (VarE t)) [])
+		['emptyM, 'nullM, 'lookupM, 'lookupIxM, 'assocAtM, 'alterM, 'alterLookupM, 'traverseWithKeyM,
+			'foldWithKeyM, 'foldlWithKeyM, 'mapEitherM, 'splitLookupM, 'unionM, 'isectM, 'diffM, 'extractM,
+			'isSubmapM, 'fromListM, 'fromAscListM, 'fromDistAscListM]
+		['emptyT, 'nullT, 'lookupT, 'lookupIxT, 'assocAtT, 'alterT, 'alterLookupT, 'traverseWithKeyT,
+			'foldWithKeyT, 'foldlWithKeyT, 'mapEitherT, 'splitLookupT, 'unionT, 'isectT, 'diffT, 'extractT,
+			'isSubmapT, 'fromListT, 'fromAscListT, 'fromDistAscListT]
 	k <- mkVar "k"
 	let triekey = ConT ''TrieKey
 	let triemap = ConT ''TrieMap
diff --git a/Data/TrieMap/Rep/Instances.hs b/Data/TrieMap/Rep/Instances.hs
--- a/Data/TrieMap/Rep/Instances.hs
+++ b/Data/TrieMap/Rep/Instances.hs
@@ -251,10 +251,6 @@
 	toRep = toRep . ISet.toList
 	fromRep = ISet.fromDistinctAscList . fromRep
 
-$(genRepT [d|
-   instance ReprT IMap.IntMap where
-   	toRepTMap f m = List [(toRep k, f a) | (k, a) <- IMap.assocs m]
-	fromRepTMap f (List xs) = IMap.fromDistinctAscList [(fromRep k, f a) | (k, a) <- xs] |])
 
 type instance RepT Seq.Seq = []
 type instance Rep (Seq.Seq a) = [Rep a]
diff --git a/Data/TrieMap/Rep/TH.hs b/Data/TrieMap/Rep/TH.hs
--- a/Data/TrieMap/Rep/TH.hs
+++ b/Data/TrieMap/Rep/TH.hs
@@ -31,14 +31,10 @@
 genRepT :: Q [Dec] -> Q [Dec]
 genRepT decs = do
 	iT@(InstanceD cxt (reprt `AppT` f) _:_) <- decs
-	(InstanceD _ _ myDecs:_) <- [d|
-		instance (ReprT f, Repr a) => Repr (f a) where
-			toRep = toRepTMap toRep
-			fromRep = fromRepTMap fromRep
-		|]
+	let myDecs = [ValD (VarP 'toRep) (NormalB (AppE (VarE 'toRepTMap) (VarE 'toRep))) [],
+		ValD (VarP 'fromRep) (NormalB (AppE (VarE 'fromRepTMap) (VarE 'fromRep))) []]
 	a <- mkVar "a"
-	repr <- conT ''Repr
-	return (InstanceD (repr `AppT` a:cxt) (repr `AppT` (f `AppT` a)) myDecs :iT)
+	return (InstanceD (ClassP ''Repr [a]:cxt) (ConT ''Repr `AppT` (f `AppT` a)) myDecs :iT)
 
 (~>) :: Type -> Type -> Type
 a ~> b = AppT (AppT ArrowT a) b
diff --git a/Data/TrieMap/Representation.hs b/Data/TrieMap/Representation.hs
--- a/Data/TrieMap/Representation.hs
+++ b/Data/TrieMap/Representation.hs
@@ -1,6 +1,14 @@
+{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
 module Data.TrieMap.Representation (Repr(..), ReprT(..), Rep, RepT) where
 
 import Data.TrieMap.Rep
 import Data.TrieMap.Rep.Instances
+import Data.TrieMap.Rep.TH
 import Data.TrieMap.Regular.Rep
+import Data.TrieMap.Regular.Base
+import qualified Data.IntMap as IMap
 
+$(genRepT [d|
+   instance ReprT IMap.IntMap where
+   	toRepTMap f m = List [(toRep k, f a) | (k, a) <- IMap.assocs m]
+	fromRepTMap f (List xs) = IMap.fromDistinctAscList [(fromRep k, f a) | (k, a) <- xs] |])
diff --git a/TrieMap.cabal b/TrieMap.cabal
--- a/TrieMap.cabal
+++ b/TrieMap.cabal
@@ -1,5 +1,5 @@
 name:		     TrieMap
-version:             0.5.4
+version:             0.6.0
 tested-with:	     GHC
 category:            Algorithms
 synopsis:	     Automatic type inference of generalized tries.
