regular 0.2.1 → 0.2.2
raw patch · 4 files changed
+32/−12 lines, 4 filesdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
+ Generics.Regular.Functions.GMap: class Functor f :: (* -> *)
+ Generics.Regular.Functions.GMap: fmap :: (Functor f) => (a -> b) -> f a -> f b
Files
- examples/Test.hs +1/−0
- regular.cabal +10/−2
- src/Generics/Regular/Functions/Read.hs +0/−2
- src/Generics/Regular/TH.hs +21/−8
examples/Test.hs view
@@ -9,6 +9,7 @@ import Generics.Regular.Functions import qualified Generics.Regular.Functions.Show as G import qualified Generics.Regular.Functions.Read as G+import Generics.Regular.Functions.Eq -- Datatype representing logical expressions
regular.cabal view
@@ -1,5 +1,5 @@ name: regular-version: 0.2.1+version: 0.2.2 synopsis: Generic programming library for regular datatypes. description: @@ -34,6 +34,9 @@ ChangeLog CREDITS +flag th24+ description: Indicates that Template Haskell 2.4 or greater is available.+ library hs-source-dirs: src exposed-modules: Generics.Regular@@ -54,5 +57,10 @@ Generics.Regular.Functions.Show Generics.Regular.Functions.Zip - build-depends: base >= 4.0 && < 5, template-haskell >= 2.2 && < 2.4+ build-depends: base >= 4.0 && < 5+ if flag(th24)+ build-depends: template-haskell >=2.4 && <2.5+ cpp-options: -DTH_TYVARBNDR+ else+ build-depends: template-haskell >= 2.2 && < 2.4 ghc-options: -Wall
src/Generics/Regular/Functions/Read.hs view
@@ -36,8 +36,6 @@ import Text.Read hiding (readsPrec, readPrec, read, Read) import Prelude hiding (readsPrec, read, Read) import qualified Prelude as P (readsPrec, Read)-import Text.Read.Lex-import Text.ParserCombinators.ReadPrec -- * Count the number of terms in a product
src/Generics/Regular/TH.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TemplateHaskell, CPP #-} {-# OPTIONS_GHC -w #-} -----------------------------------------------------------------------------@@ -80,7 +80,7 @@ deriveInst t = do i <- reify t- let typ = foldl (\a -> AppT a . VarT) (ConT t) (typeVariables i)+ let typ = foldl (\a -> AppT a . VarT . tyVarBndrToName) (ConT t) (typeVariables i) fcs <- mkFrom t 1 0 t tcs <- mkTo t 1 0 t liftM (:[]) $@@ -115,11 +115,24 @@ is <- mapM (mkSelectInstance n) cs return $ concat (ds ++ is) +#ifdef TH_TYVARBNDR+typeVariables :: Info -> [TyVarBndr]+#else typeVariables :: Info -> [Name]+#endif typeVariables (TyConI (DataD _ _ tv _ _)) = tv typeVariables (TyConI (NewtypeD _ _ tv _ _)) = tv typeVariables _ = [] +#ifdef TH_TYVARBNDR+tyVarBndrToName :: TyVarBndr -> Name+tyVarBndrToName (PlainTV name) = name+tyVarBndrToName (KindedTV name _) = name+#else+tyVarBndrToName :: Name -> Name+tyVarBndrToName = id+#endif+ stripRecordNames :: Con -> Con stripRecordNames (RecC n f) = NormalC n (map (\(_, s, t) -> (s, t)) f)@@ -189,9 +202,9 @@ i <- reify n let b = case i of TyConI (DataD _ dt vs cs _) ->- foldr1 sum (map (pfCon (dt, vs)) cs)+ foldr1 sum (map (pfCon (dt, map tyVarBndrToName vs)) cs) TyConI (NewtypeD _ dt vs c _) ->- pfCon (dt, vs) c+ pfCon (dt, map tyVarBndrToName vs) c TyConI (TySynD t _ _) -> conT ''K `appT` conT t _ -> error "unknown construct" @@ -240,9 +253,9 @@ i <- reify n let b = case i of TyConI (DataD _ dt vs cs _) ->- zipWith (fromCon wrapE ns (dt, vs) (length cs)) [0..] cs+ zipWith (fromCon wrapE ns (dt, map tyVarBndrToName vs) (length cs)) [0..] cs TyConI (NewtypeD _ dt vs c _) ->- [fromCon wrapE ns (dt, vs) 1 0 c]+ [fromCon wrapE ns (dt, map tyVarBndrToName vs) 1 0 c] TyConI (TySynD t _ _) -> [clause [varP (field 0)] (normalB (wrapE $ conE 'K `appE` varE (field 0))) []] _ -> error "unknown construct"@@ -256,9 +269,9 @@ i <- reify n let b = case i of TyConI (DataD _ dt vs cs _) ->- zipWith (toCon wrapP ns (dt, vs) (length cs)) [0..] cs+ zipWith (toCon wrapP ns (dt, map tyVarBndrToName vs) (length cs)) [0..] cs TyConI (NewtypeD _ dt vs c _) ->- [toCon wrapP ns (dt, vs) 1 0 c]+ [toCon wrapP ns (dt, map tyVarBndrToName vs) 1 0 c] TyConI (TySynD t _ _) -> [clause [wrapP $ conP 'K [varP (field 0)]] (normalB $ varE (field 0)) []] _ -> error "unknown construct"