Skip to content

Instantly share code, notes, and snippets.

@cocreature
Last active August 29, 2015 14:16
Show Gist options
  • Save cocreature/dceb81f856ef30c69293 to your computer and use it in GitHub Desktop.
Save cocreature/dceb81f856ef30c69293 to your computer and use it in GitHub Desktop.
--- a/haskell-src-meta.cabal
+++ b/haskell-src-meta.cabal
@@ -28,7 +28,7 @@
if impl(ghc >=7.4)
build-depends:
- template-haskell >=2.7 && <2.10
+ template-haskell >=2.7 && <2.11
else
build-depends:
template-haskell >=2.4 && <2.7,
--- a/src/Language/Haskell/Meta/Syntax/Translate.hs
+++ b/src/Language/Haskell/Meta/Syntax/Translate.hs
@@ -384,9 +384,15 @@
toCxt :: Hs.Context -> Cxt
toCxt = fmap toPred
where
+#if MIN_VERSION_template_haskell(2,10,0)
+ toPred (Hs.ClassA n ts) = foldl' AppT (ConT (toName n)) (fmap toType ts)
+ toPred (Hs.InfixA t1 n t2) = foldl' AppT (ConT (toName n)) (fmap toType [t1,t2])
+ toPred (Hs.EqualP t1 t2) = foldl' AppT EqualityT (fmap toType [t1,t2])
+#else
toPred (Hs.ClassA n ts) = ClassP (toName n) (fmap toType ts)
toPred (Hs.InfixA t1 n t2) = ClassP (toName n) (fmap toType [t1, t2])
toPred (Hs.EqualP t1 t2) = EqualP (toType t1) (toType t2)
+#endif
toPred [email protected]{} = noTH "toCxt" a
foldAppT :: Type -> [Type] -> Type
--- a/src/Language/Haskell/Meta/Utils.hs
+++ b/src/Language/Haskell/Meta/Utils.hs
@@ -166,6 +166,9 @@
unVarT (VarT n) = PlainTV n
renamePreds = renameThings renamePred
+#if MIN_VERSION_template_haskell(2,10,0)
+ renamePred = renameT
+#else
renamePred env new (ClassP n ts) = let
(ts', env', new') = renameTs env new [] ts
in (ClassP (normaliseName n) ts', env', new')
@@ -174,7 +177,7 @@
(t1', env1, new1) = renameT env new t1
(t2', env2, new2) = renameT env1 new1 t2
in (EqualP t1' t2', env2, new2)
-
+#endif
-- | Remove qualification, etc.
normaliseName :: Name -> Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment