diff --git a/src/Language/Haskell/TH/Extras.hs b/src/Language/Haskell/TH/Extras.hs index ea57eed..eb3b2fe 100644 --- a/src/Language/Haskell/TH/Extras.hs +++ b/src/Language/Haskell/TH/Extras.hs @@ -8,6 +8,7 @@ import Data.Set (Set) import qualified Data.Set as Set import Language.Haskell.TH import Language.Haskell.TH.Syntax +import Language.Haskell.TH.Datatype.TyVarBndr intIs64 :: Bool intIs64 = toInteger (maxBound :: Int) > 2^(32 :: Integer) @@ -46,16 +47,10 @@ argTypesOfCon (GadtC _ args _) = map snd args argTypesOfCon (RecGadtC _ args _) = [t | (_,_,t) <- args] #endif -nameOfBinder :: TyVarBndr -> Name -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 700 -nameOfBinder (PlainTV n) = n -nameOfBinder (KindedTV n _) = n -#else -nameOfBinder = id -type TyVarBndr = Name -#endif +nameOfBinder :: TyVarBndr_ a -> Name +nameOfBinder = tvName -varsBoundInCon :: Con -> [TyVarBndr] +varsBoundInCon :: Con -> [TyVarBndrSpec] varsBoundInCon (ForallC bndrs _ con) = bndrs ++ varsBoundInCon con varsBoundInCon _ = [] @@ -149,7 +144,7 @@ headOfType ty = error $ "headOfType: Unhandled type: " ++ show ty occursInType :: Name -> Type -> Bool occursInType var ty = case ty of ForallT bndrs _ ty' - | any (var ==) (map nameOfBinder bndrs) + | any (var ==) (map tvName bndrs) -> False | otherwise -> occursInType var ty' @@ -182,7 +177,7 @@ substVarsWith topVars resultType argType = subst Set.empty argType -- of Template Haskell. #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 710 ForallT bndrs cxt t -> - let bs' = Set.union bs (Set.fromList (map nameOfBinder bndrs)) + let bs' = Set.union bs (Set.fromList (map tvName bndrs)) in ForallT bndrs (map (subst bs') cxt) (subst bs' t) #else ForallT {} -> error "substVarsWith: ForallT substitutions have not been implemented for GHCs prior to 7.10" @@ -251,7 +246,7 @@ tyConArity n = do -- its declaration, and the arity of the kind of type being defined (i.e. how many more arguments would -- need to be supplied in addition to the bound parameters in order to obtain an ordinary type of kind *). -- If the supplied 'Name' is anything other than a data or newtype, produces an error. -tyConArity' :: Name -> Q ([TyVarBndr], Int) +tyConArity' :: Name -> Q ([TyVarBndrUnit], Int) tyConArity' n = do r <- reify n return $ case r of diff --git a/th-extras.cabal b/th-extras.cabal index 5031a5d..3f7bf7a 100644 --- a/th-extras.cabal +++ b/th-extras.cabal @@ -2,7 +2,7 @@ name: th-extras version: 0.0.0.4 stability: experimental -cabal-version: >= 1.6 +cabal-version: >= 1.8 build-type: Simple author: James Cook @@ -34,7 +34,8 @@ Library exposed-modules: Language.Haskell.TH.Extras build-depends: base >= 3 && < 5, containers, - template-haskell - + template-haskell < 2.18, + th-abstraction >= 0.4 && < 0.5 + if flag(base4) build-depends: base >= 4, syb