packages feed

geniplate 0.6.0.1 → 0.6.0.2

raw patch · 3 files changed

+47/−71 lines, 3 filesdep ~template-haskell

Dependency ranges changed: template-haskell

Files

Data/Generics/Geniplate.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances, PatternGuards, CPP #-}+{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, PatternGuards #-} 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 Uniplate.+---- Overloaded interface, same as Usniplate  -- | Class for 'universeBi'. class UniverseBi s t where@@ -42,15 +42,12 @@  -- | Create a 'UniverseBi' instance. -- The 'TypeQ' argument should be a pair; the /source/ and /target/ types for 'universeBi'.-instanceUniverseBi :: TypeQ         -- ^(source, target) types-                   -> Q [Dec]+instanceUniverseBi :: TypeQ -> 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]      -- ^types not touched by 'universeBi'-                    -> TypeQ        -- ^(source, target) types-                    -> Q [Dec]+instanceUniverseBiT :: [TypeQ] -> TypeQ -> Q [Dec] instanceUniverseBiT stops ty = instanceUniverseBiT' stops =<< ty  instanceUniverseBiT' :: [TypeQ] -> Type -> Q [Dec]@@ -70,15 +67,12 @@  -- | Create a 'TransformBi' instance. -- The 'TypeQ' argument should be a pair; the /inner/ and /outer/ types for 'transformBi'.-instanceTransformBi :: TypeQ        -- ^(inner, outer) types-                    -> Q [Dec]+instanceTransformBi :: TypeQ -> 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]      -- ^types not touched by 'transformBi'-                     -> TypeQ        -- ^(inner, outer) types-                     -> Q [Dec]+instanceTransformBiT :: [TypeQ] -> TypeQ -> Q [Dec] instanceTransformBiT stops ty = instanceTransformBiT' stops =<< ty  instanceTransformBiT' :: [TypeQ] -> Type -> Q [Dec]@@ -93,16 +87,11 @@ 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]@@ -122,15 +111,12 @@ -- | 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             -- ^function of type @S -> [T]@-              -> Q Exp+genUniverseBi :: Name -> Q Exp genUniverseBi = genUniverseBiT []  -- | Same as 'genUniverseBi', but does not look inside any types mention in the -- list of types.-genUniverseBiT :: [TypeQ]         -- ^types not touched by 'universeBi'-               -> Name            -- ^function of type @S -> [T]@-               -> Q Exp+genUniverseBiT :: [TypeQ] -> Name -> Q Exp genUniverseBiT stops name = do     (_tvs, from, tos) <- getNameType name     let to = unList tos@@ -148,17 +134,9 @@     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@@ -348,7 +326,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) = expandSyn t   -- Ignore kind synonyms+expandSyn (SigT t k) = liftM (flip SigT k) $ expandSyn t expandSyn t = return t  expandSynApp :: (Quasi q) => Type -> [Type] -> q Type@@ -374,8 +352,7 @@ -- | 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       -- ^function of type @(S->S) -> T -> T@-               -> Q Exp+genTransformBi :: Name -> Q Exp genTransformBi = genTransformBiT []  -- | Same as 'genTransformBi', but does not look inside any types mention in the
examples/output view
@@ -1,32 +1,33 @@-[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]+./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]
geniplate.cabal view
@@ -1,6 +1,6 @@ Name:           geniplate Cabal-Version:  >= 1.2-Version:        0.6.0.1+Version:        0.6.0.2 License:        BSD3 Author:         Lennart Augustsson Maintainer:     Lennart Augustsson@@ -15,7 +15,5 @@       examples/output  Library-  Build-Depends: base >= 4 && < 5.0,-                 template-haskell < 2.8,-                 mtl+  Build-Depends: base >= 4 && < 5.0, template-haskell < 2.9, mtl   Exposed-modules:      Data.Generics.Geniplate