geniplate 0.6.0.0 → 0.6.0.1
raw patch · 3 files changed
+71/−47 lines, 3 filesdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
Files
- Data/Generics/Geniplate.hs +35/−12
- examples/output +32/−33
- geniplate.cabal +4/−2
Data/Generics/Geniplate.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}+{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances, PatternGuards, CPP #-} module Data.Generics.Geniplate( genUniverseBi, genUniverseBiT, genTransformBi, genTransformBiT,@@ -15,7 +15,7 @@ import Language.Haskell.TH.Syntax hiding (lift) import System.IO ----- Overloaded interface, same as Usniplate+---- Overloaded interface, same as Uniplate. -- | Class for 'universeBi'. class UniverseBi s t where@@ -42,12 +42,15 @@ -- | Create a 'UniverseBi' instance. -- The 'TypeQ' argument should be a pair; the /source/ and /target/ types for 'universeBi'.-instanceUniverseBi :: TypeQ -> Q [Dec]+instanceUniverseBi :: TypeQ -- ^(source, target) types+ -> Q [Dec] instanceUniverseBi = instanceUniverseBiT [] -- | Create a 'UniverseBi' instance with certain types being abstract. -- The 'TypeQ' argument should be a pair; the /source/ and /target/ types for 'universeBi'.-instanceUniverseBiT :: [TypeQ] -> TypeQ -> Q [Dec]+instanceUniverseBiT :: [TypeQ] -- ^types not touched by 'universeBi'+ -> TypeQ -- ^(source, target) types+ -> Q [Dec] instanceUniverseBiT stops ty = instanceUniverseBiT' stops =<< ty instanceUniverseBiT' :: [TypeQ] -> Type -> Q [Dec]@@ -67,12 +70,15 @@ -- | Create a 'TransformBi' instance. -- The 'TypeQ' argument should be a pair; the /inner/ and /outer/ types for 'transformBi'.-instanceTransformBi :: TypeQ -> Q [Dec]+instanceTransformBi :: TypeQ -- ^(inner, outer) types+ -> Q [Dec] instanceTransformBi = instanceTransformBiT [] -- | Create a 'TransformBi' instance with certain types being abstract. -- The 'TypeQ' argument should be a pair; the /inner/ and /outer/ types for 'transformBi'.-instanceTransformBiT :: [TypeQ] -> TypeQ -> Q [Dec]+instanceTransformBiT :: [TypeQ] -- ^types not touched by 'transformBi'+ -> TypeQ -- ^(inner, outer) types+ -> Q [Dec] instanceTransformBiT stops ty = instanceTransformBiT' stops =<< ty instanceTransformBiT' :: [TypeQ] -> Type -> Q [Dec]@@ -87,11 +93,16 @@ instanceTransformBiT' _ t = genError "instanceTransformBiT: the argument should be of the form [t| (S, T) |]" -- | Create a 'TransformBiM' instance.-instanceTransformBiM :: TypeQ -> TypeQ -> Q [Dec]+instanceTransformBiM :: TypeQ+ -> TypeQ+ -> Q [Dec] instanceTransformBiM = instanceTransformBiMT [] -- | Create a 'TransformBiM' instance with certain types being abstract.-instanceTransformBiMT :: [TypeQ] -> TypeQ -> TypeQ -> Q [Dec]+instanceTransformBiMT :: [TypeQ]+ -> TypeQ+ -> TypeQ+ -> Q [Dec] instanceTransformBiMT stops mndq ty = instanceTransformBiMT' stops mndq =<< ty instanceTransformBiMT' :: [TypeQ] -> TypeQ -> Type -> Q [Dec]@@ -111,12 +122,15 @@ -- | Generate TH code for a function that extracts all subparts of a certain type. -- The argument to 'genUniverseBi' is a name with the type @S -> [T]@, for some types -- @S@ and @T@. The function will extract all subparts of type @T@ from @S@.-genUniverseBi :: Name -> Q Exp+genUniverseBi :: Name -- ^function of type @S -> [T]@+ -> Q Exp genUniverseBi = genUniverseBiT [] -- | Same as 'genUniverseBi', but does not look inside any types mention in the -- list of types.-genUniverseBiT :: [TypeQ] -> Name -> Q Exp+genUniverseBiT :: [TypeQ] -- ^types not touched by 'universeBi'+ -> Name -- ^function of type @S -> [T]@+ -> Q Exp genUniverseBiT stops name = do (_tvs, from, tos) <- getNameType name let to = unList tos@@ -134,9 +148,17 @@ qReport b = lift . qReport b qRecover = error "Data.Generics.Geniplate: qRecover not implemented" qReify = lift . qReify+#if MIN_VERSION_template_haskell(2,7,0)+ qReifyInstances n = lift . qReifyInstances n+#else qClassInstances n = lift . qClassInstances n+#endif qLocation = lift qLocation qRunIO = lift . qRunIO+#if MIN_VERSION_template_haskell(2,7,0)+ qLookupName ns = lift . qLookupName ns+ qAddDependentFile = lift . qAddDependentFile+#endif uniBiQ :: [TypeQ] -> Type -> Type -> Q ([Dec], Exp) uniBiQ stops from ato = do@@ -326,7 +348,7 @@ expandSyn (ForallT tvs ctx t) = liftM (ForallT tvs ctx) $ expandSyn t expandSyn t@AppT{} = expandSynApp t [] expandSyn t@ConT{} = expandSynApp t []-expandSyn (SigT t k) = liftM (flip SigT k) $ expandSyn t+expandSyn (SigT t k) = expandSyn t -- Ignore kind synonyms expandSyn t = return t expandSynApp :: (Quasi q) => Type -> [Type] -> q Type@@ -352,7 +374,8 @@ -- | Generate TH code for a function that transforms all subparts of a certain type. -- The argument to 'genTransformBi' is a name with the type @(S->S) -> T -> T@, for some types -- @S@ and @T@. The function will transform all subparts of type @S@ inside @T@ using the given function.-genTransformBi :: Name -> Q Exp+genTransformBi :: Name -- ^function of type @(S->S) -> T -> T@+ -> Q Exp genTransformBi = genTransformBiT [] -- | Same as 'genTransformBi', but does not look inside any types mention in the
examples/output view
@@ -1,33 +1,32 @@-./Main-[12,1,2,345,3,4,5,6] -[1,2,3,4,5,6] -[] -[True,True,True,False,True,False,True,True,False,True,False,False,False,True] -[Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True),Bin (MT True) 'a' True (MT False),MT True,MT False,MT True] -[[1,2],[2],[]] -[(True,T {x = 2, y = "a"}),(False,T {x = 3, y = "b"})] -Bin (Bin (MT False) 'a' False (MT True)) 'a' True (MT False) -Bin (Bin (MT False) False False (MT True)) False True (MT False) -Bin (Bin (MT True) 'a' False (MT False)) 'a' True (MT True) -Just [1,2,3] -Nothing -Just [(1,True)] -3 -3 -Bin (Bin (MT True) 103 True (MT False)) 103 False (MT True) -True -True -True -False -True -False -True -Bin (Bin (MT False) False False (MT True)) False True (MT False) -MT True -MT False -Bin (MT True) 'a' True (MT False) -MT True -Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True) -Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True) -[()] -[2,11,101] +[12,1,2,345,3,4,5,6]+[1,2,3,4,5,6]+[]+[True,True,True,False,True,False,True,True,False,True,False,False,False,True]+[Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True),Bin (MT True) 'a' True (MT False),MT True,MT False,MT True]+[[1,2],[2],[]]+[(True,T {x = 2, y = "a"}),(False,T {x = 3, y = "b"})]+Bin (Bin (MT False) 'a' False (MT True)) 'a' True (MT False)+Bin (Bin (MT False) False False (MT True)) False True (MT False)+Bin (Bin (MT True) 'a' False (MT False)) 'a' True (MT True)+Just [1,2,3]+Nothing+Just [(1,True)]+3+3+Bin (Bin (MT True) 103 True (MT False)) 103 False (MT True)+True+True+True+False+True+False+True+Bin (Bin (MT False) False False (MT True)) False True (MT False)+MT True+MT False+Bin (MT True) 'a' True (MT False)+MT True+Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True)+Bin (Bin (MT True) 'a' True (MT False)) 'a' False (MT True)+[()]+[2,11,101]
geniplate.cabal view
@@ -1,6 +1,6 @@ Name: geniplate Cabal-Version: >= 1.2-Version: 0.6.0.0+Version: 0.6.0.1 License: BSD3 Author: Lennart Augustsson Maintainer: Lennart Augustsson@@ -15,5 +15,7 @@ examples/output Library- Build-Depends: base >= 4 && < 5.0, template-haskell, mtl+ Build-Depends: base >= 4 && < 5.0,+ template-haskell < 2.8,+ mtl Exposed-modules: Data.Generics.Geniplate