packages feed

ghc-syb-utils 0.2.2 → 0.2.3

raw patch · 2 files changed

+54/−16 lines, 2 filesdep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ghc

API changes (from Hackage documentation)

+ GHC.SYB.Utils: nameSetElems :: NameSet -> [Name]

Files

GHC/SYB/Utils.hs view
@@ -176,24 +176,33 @@ import Data.Generics  -- import qualified GHC.Paths-import PprTyThing+import PprTyThing() import DynFlags-import GHC-import Outputable-import SrcLoc+import GHC hiding (moduleName)+import Outputable hiding (space)+import SrcLoc() import qualified OccName(occNameString) import Bag(Bag,bagToList) import Var(Var) import FastString(FastString)+#if __GLASGOW_HASKELL__ >= 709+import NameSet(NameSet,nameSetElems)+#else import NameSet(NameSet,nameSetToList)+#endif  #if __GLASGOW_HASKELL__ < 700 import GHC.SYB.Instances-#endif +#endif  import Control.Monad import Data.List +#if __GLASGOW_HASKELL__ < 709+nameSetElems :: NameSet -> [Name]+nameSetElems = nameSetToList+#endif+ showSDoc_ :: SDoc -> String #if __GLASGOW_HASKELL__ >= 707 showSDoc_ = showSDoc unsafeGlobalDynFlags@@ -218,13 +227,16 @@           `extQ` name `extQ` occName `extQ` moduleName `extQ` var `extQ` dataCon           `extQ` overLit           `extQ` bagName `extQ` bagRdrName `extQ` bagVar `extQ` nameSet-          `extQ` postTcType `extQ` fixity+#if __GLASGOW_HASKELL__ <= 708+          `extQ` postTcType+#endif+          `extQ` fixity   where generic :: Data a => a -> String         generic t = indent n ++ "(" ++ showConstr (toConstr t)                  ++ space (concat (intersperse " " (gmapQ (showData stage (n+1)) t))) ++ ")"         space "" = ""         space s  = ' ':s-        indent n = "\n" ++ replicate n ' ' +        indent i = "\n" ++ replicate i ' '         string     = show :: String -> String         fastString = ("{FastString: "++) . (++"}") . show :: FastString -> String         list l     = indent n ++ "[" @@ -250,22 +262,30 @@         nameSet | stage `elem` [Parser,TypeChecker]                  = const ("{!NameSet placeholder here!}") :: NameSet -> String                 | otherwise     -                = ("{NameSet: "++) . (++"}") . list . nameSetToList +                = ("{NameSet: "++) . (++"}") . list . nameSetElems  +#if __GLASGOW_HASKELL__ <= 708         postTcType | stage<TypeChecker = const "{!type placeholder here?!}" :: PostTcType -> String                    | otherwise     = showSDoc_ . ppr :: Type -> String-+#endif         fixity | stage<Renamer = const "{!fixity placeholder here?!}" :: GHC.Fixity -> String                | otherwise     = ("{Fixity: "++) . (++"}") . showSDoc_ . ppr :: GHC.Fixity -> String + -- | Like 'everything', but avoid known potholes, based on the 'Stage' that --   generated the Ast. everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r everythingStaged stage k z f x -  | (const False `extQ` postTcType `extQ` fixity `extQ` nameSet) x = z+  | (const False+#if __GLASGOW_HASKELL__ <= 708+      `extQ` postTcType+#endif+      `extQ` fixity `extQ` nameSet) x = z   | otherwise = foldl k (f x) (gmapQ (everythingStaged stage k z f) x)   where nameSet    = const (stage `elem` [Parser,TypeChecker]) :: NameSet -> Bool+#if __GLASGOW_HASKELL__ <= 708         postTcType = const (stage<TypeChecker)                 :: PostTcType -> Bool+#endif         fixity     = const (stage<Renamer)                     :: GHC.Fixity -> Bool  -- | A variation of 'everything', using a 'GenericQ Bool' to skip@@ -279,12 +299,18 @@ -- Question: how to handle partial results in the otherwise step? everythingButStaged :: Stage -> (r -> r -> r) -> r -> GenericQ (r,Bool) -> GenericQ r everythingButStaged stage k z f x-  | (const False `extQ` postTcType `extQ` fixity `extQ` nameSet) x = z+  | (const False+#if __GLASGOW_HASKELL__ <= 708+       `extQ` postTcType+#endif+       `extQ` fixity `extQ` nameSet) x = z   | stop == True = v   | otherwise = foldl k v (gmapQ (everythingButStaged stage k z f) x)   where (v, stop) = f x         nameSet    = const (stage `elem` [Parser,TypeChecker]) :: NameSet -> Bool+#if __GLASGOW_HASKELL__ <= 708         postTcType = const (stage<TypeChecker)                 :: PostTcType -> Bool+#endif         fixity     = const (stage<Renamer)                     :: GHC.Fixity -> Bool  -- | Look up a subterm by means of a maybe-typed filter.@@ -304,10 +330,16 @@ somewhereStaged :: MonadPlus m => Stage -> GenericM m -> GenericM m  somewhereStaged stage f x-  | (const False `extQ` postTcType `extQ` fixity `extQ` nameSet) x = mzero+  | (const False+#if __GLASGOW_HASKELL__ <= 708+       `extQ` postTcType+#endif+       `extQ` fixity `extQ` nameSet) x = mzero   | otherwise = f x `mplus` gmapMp (somewhereStaged stage f) x   where nameSet    = const (stage `elem` [Parser,TypeChecker]) :: NameSet -> Bool+#if __GLASGOW_HASKELL__ <= 708         postTcType = const (stage<TypeChecker)                 :: PostTcType -> Bool+#endif         fixity     = const (stage<Renamer)                     :: GHC.Fixity -> Bool  -- ---------------------------------------------------------------------@@ -337,12 +369,17 @@  -- Bottom-up order is also reflected in order of do-actions everywhereMStaged stage f x-  | (const False `extQ` postTcType `extQ` fixity `extQ` nameSet) x = return x+  | (const False+#if __GLASGOW_HASKELL__ <= 708+       `extQ` postTcType+#endif+       `extQ` fixity `extQ` nameSet) x = return x   | otherwise = do x' <- gmapM (everywhereMStaged stage f) x                    f x'   where nameSet    = const (stage `elem` [Parser,TypeChecker]) :: NameSet -> Bool+#if __GLASGOW_HASKELL__ <= 708         postTcType = const (stage<TypeChecker)                 :: PostTcType -> Bool+#endif         fixity     = const (stage<Renamer)                     :: GHC.Fixity -> Bool-  
ghc-syb-utils.cabal view
@@ -1,5 +1,5 @@ name:            ghc-syb-utils-version:         0.2.2+version:         0.2.3 license:         BSD3 license-file:    LICENSE author:          Claus Reinke@@ -12,7 +12,7 @@ stability:       provisional build-type:      Simple cabal-version:   >= 1.6-tested-with:     GHC ==6.10.4, GHC ==6.12.1, GHC ==7.4.2, GHC ==7.6.3+tested-with:     GHC ==7.8.3, GHC ==7.10.0  library   build-depends:   base >= 4 && < 5@@ -28,5 +28,6 @@    hs-source-dirs:  .   extensions:      Rank2Types, CPP+  ghc-options:    -Wall    exposed-modules: GHC.SYB.Utils