multirec 0.7.5 → 0.7.6
raw patch · 2 files changed
+38/−3 lines, 2 filesdep ~template-haskell
Dependency ranges changed: template-haskell
Files
- multirec.cabal +3/−3
- src/Generics/MultiRec/TH.hs +35/−0
multirec.cabal view
@@ -1,5 +1,5 @@ name: multirec-version: 0.7.5+version: 0.7.6 license: BSD3 license-file: LICENSE author: Alexey Rodriguez,@@ -38,7 +38,7 @@ stability: experimental build-type: Simple cabal-version: >= 1.6-tested-with: GHC == 7.0.4+tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 extra-source-files: examples/All.hs examples/AST.hs examples/ASTUse.hs@@ -81,4 +81,4 @@ Generics.MultiRec.TEq build-depends: base >= 3.0 && < 5,- template-haskell >= 2.4 && < 3+ template-haskell >= 2.4 && < 2.12
src/Generics/MultiRec/TH.hs view
@@ -141,7 +141,11 @@ -- its constructor names, which are also the names of the datatypes -- that are part of the family. extractConstructorNames :: [Name] -> Info -> [(Name, [Name])]+#if MIN_VERSION_template_haskell(2,11,0)+extractConstructorNames ps (TyConI (DataD _ _ _ _ cs _)) = concatMap extractFrom cs+#else extractConstructorNames ps (TyConI (DataD _ _ _ cs _)) = concatMap extractFrom cs+#endif where extractFrom :: Con -> [(Name, [Name])] extractFrom (ForallC _ eqs c) = map (\ (n, _) -> (n, concatMap extractEq eqs)) (extractFrom c)@@ -170,7 +174,11 @@ -- | Process the reified info of the index GADT, and extract -- its type parameters. extractParameters :: Info -> [Name]+#if MIN_VERSION_template_haskell(2,11,0)+extractParameters (TyConI (DataD _ _ ns _ _ _)) = concatMap extractFromBndr ns+#else extractParameters (TyConI (DataD _ _ ns _ _)) = concatMap extractFromBndr ns+#endif extractParameters (TyConI (TySynD _ ns _)) = concatMap extractFromBndr ns extractParameters _ = [] @@ -195,7 +203,11 @@ i <- reify n -- runIO (print i) let cs = case i of+#if MIN_VERSION_template_haskell(2,11,0)+ TyConI (DataD _ _ _ _ cs _) -> cs+#else TyConI (DataD _ _ _ cs _) -> cs+#endif _ -> [] ds <- mapM mkData cs is <- mapM mkInstance cs@@ -205,7 +217,11 @@ -- the same name. mkData :: Con -> Q Dec mkData (NormalC n _) =+#if MIN_VERSION_template_haskell(2,11,0)+ dataD (cxt []) (remakeName n) [] Nothing [] (cxt [])+#else dataD (cxt []) (remakeName n) [] [] []+#endif mkData r@(RecC _ _) = mkData (stripRecordNames r) mkData (InfixC t1 n t2) =@@ -234,10 +250,17 @@ mkInstance c mkInstance (InfixC t1 n t2) = do+#if MIN_VERSION_template_haskell(2,11,0)+ i <- reifyFixity n+ let fi = case i of+ Just f -> convertFixity f+ Nothing -> Prefix+#else i <- reify n let fi = case i of DataConI _ _ _ f -> convertFixity f _ -> Prefix+#endif instanceD (cxt []) (appT (conT ''Constructor) (conT $ remakeName n)) [funD 'conName [clause [wildP] (normalB (stringE (nameBase n))) []], funD 'conFixity [clause [wildP] (normalB (fixity fi)) []]]@@ -258,7 +281,11 @@ -- runIO $ putStrLn $ "processing " ++ show n let b = case i of -- datatypes are nested binary sums of their constructors+#if MIN_VERSION_template_haskell(2,11,0)+ TyConI (DataD _ _ _ _ cs _) ->+#else TyConI (DataD _ _ _ cs _) ->+#endif foldr1 sum (map (pfCon ns (zip qs rs)) cs) -- type synonyms are always treated as constants TyConI (TySynD t _ _) ->@@ -332,7 +359,11 @@ i <- reify n let dn = remakeName n let b = case i of+#if MIN_VERSION_template_haskell(2,11,0)+ TyConI (DataD _ _ _ _ cs _) ->+#else TyConI (DataD _ _ _ cs _) ->+#endif zipWith (fromCon wrapE ns dn (length cs)) [0..] cs TyConI (TySynD t _ _) -> [clause [conP dn [], varP (field 0)] (normalB (wrapE $ conE 'K `appE` varE (field 0))) []]@@ -347,7 +378,11 @@ i <- reify n let dn = remakeName n let b = case i of+#if MIN_VERSION_template_haskell(2,11,0)+ TyConI (DataD _ _ _ _ cs _) ->+#else TyConI (DataD _ _ _ cs _) ->+#endif zipWith (toCon wrapP ns dn (length cs)) [0..] cs TyConI (TySynD t _ _) -> [clause [conP dn [], wrapP $ conP 'K [varP (field 0)]] (normalB $ varE (field 0)) []]