├── .gitignore ├── Setup.hs ├── Makefile ├── ghc-syb.cabal ├── LICENSE └── src └── GHC └── SYB ├── Utils.hs └── Instances.hs /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | dist/* 3 | *.hi 4 | *.o 5 | Setup.exe* 6 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | import Distribution.Simple 3 | main :: IO () 4 | main = defaultMain -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | HC=../ghc/ghc/stage2-inplace/ghc.exe 2 | PKG=../ghc/utils/ghc-pkg/install-inplace/bin/ghc-pkg.exe 3 | SETUP=./Setup.exe 4 | 5 | main: build 6 | 7 | Setup.exe: Setup.hs 8 | $(HC) --make $< 9 | 10 | configure: 11 | $(SETUP) configure --with-compiler=$(HC) --with-hc-pkg=$(PKG) --user 12 | 13 | build: 14 | $(SETUP) build 15 | 16 | install: 17 | $(SETUP) install 18 | 19 | test: 20 | ./dist/build/test/test.exe 21 | 22 | clean: 23 | $(SETUP) 24 | -------------------------------------------------------------------------------- /ghc-syb.cabal: -------------------------------------------------------------------------------- 1 | name: ghc-syb 2 | version: 0.1.2 3 | license: BSD3 4 | license-file: LICENSE 5 | author: Claus Reinke 6 | copyright: (c) Claus Reinke 2008 7 | maintainer: Thomas Schilling 8 | homepage: http://github.com/nominolo/ghc-syb 9 | description: Scrap Your Boilerplate instances and utils for the GHC API. 10 | synopsis: SYB instances for the GHC API 11 | category: Development 12 | stability: provisional 13 | build-type: Simple 14 | cabal-version: >= 1.2.3 15 | tested-with: GHC ==6.10.1 16 | -- extra-source-files: README 17 | 18 | library 19 | build-depends: base >= 4 && < 5, 20 | syb >= 0.1 && < 0.2, 21 | ghc >= 6.10 && < 6.12 22 | hs-source-dirs: src 23 | extensions: CPP, TypeSynonymInstances, StandaloneDeriving, 24 | DeriveDataTypeable, ScopedTypeVariables, 25 | RankNTypes 26 | exposed-modules: GHC.SYB.Instances, 27 | GHC.SYB.Utils 28 | if impl(ghc > 6.11.20081030) 29 | cpp-options: -DHAS_ANNOTATIONS 30 | if impl(ghc >= 6.11.20090318) 31 | cpp-options: -DCONSTRUCTOR_LIKE_IDS 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Claus Reinke 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | - Neither name of the author nor the names of its contributors may be 15 | used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND THE CONTRIBUTORS "AS 19 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY 22 | COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/GHC/SYB/Utils.hs: -------------------------------------------------------------------------------- 1 | {- | "GHC.Syb.Utils" provides common utilities for the Ghc Api, 2 | either based on Data\/Typeable or for use with Data.Generics 3 | over Ghc Api types. 4 | 5 | example output of 'showData' on 'parsedSource', 'renamedSource', and 6 | 'typecheckedSource' for a trivial @HelloWorld@ module, compared with 7 | 'ppr' output: 8 | 9 | @ 10 | ------------------------- pretty-printed parsedSource 11 | module HelloWorld where 12 | main = putStrLn "Hello, World!" 13 | ------------------------- pretty-printed renamedSource 14 | Just (HelloWorld.main = System.IO.putStrLn "Hello, World!", 15 | [import Prelude], 16 | Nothing, 17 | Nothing, 18 | 19 | (HaddockModInfo 20 | (Nothing) 21 | (Nothing) 22 | (Nothing) 23 | (Nothing))) 24 | ------------------------- pretty-printed typecheckedSource 25 | Just 29 | ------------------------- shown parsedSource 30 | 31 | (L {HelloWorld.hs:1:0} 32 | (HsModule 33 | (Just 34 | (L {HelloWorld.hs:1:7-16} {ModuleName: HelloWorld})) 35 | (Nothing) 36 | [] 37 | [ 38 | (L {HelloWorld.hs:2:0-30} 39 | (ValD 40 | (FunBind 41 | (L {HelloWorld.hs:2:0-3} 42 | (Unqual {OccName: main})) 43 | (False) 44 | (MatchGroup 45 | [ 46 | (L {HelloWorld.hs:2:0-30} 47 | (Match 48 | [] 49 | (Nothing) 50 | (GRHSs 51 | [ 52 | (L {HelloWorld.hs:2:7-30} 53 | (GRHS 54 | [] 55 | (L {HelloWorld.hs:2:7-30} 56 | (HsApp 57 | (L {HelloWorld.hs:2:7-14} 58 | (HsVar 59 | (Unqual {OccName: putStrLn}))) 60 | (L {HelloWorld.hs:2:16-30} 61 | (HsLit 62 | (HsString {FastString: "Hello, World!"})))))))] 63 | (EmptyLocalBinds))))] {!type placeholder here?!}) 64 | (WpHole) {!NameSet placeholder here!} 65 | (Nothing))))] 66 | (Nothing) 67 | (HaddockModInfo 68 | (Nothing) 69 | (Nothing) 70 | (Nothing) 71 | (Nothing)) 72 | (Nothing))) 73 | ------------------------- shown renamedSource 74 | 75 | ((,,,,) 76 | (HsGroup 77 | (ValBindsOut 78 | [ 79 | ((,) 80 | (NonRecursive) {Bag(Located (HsBind Name)): 81 | [ 82 | (L {HelloWorld.hs:2:0-30} 83 | (FunBind 84 | (L {HelloWorld.hs:2:0-3} {Name: HelloWorld.main}) 85 | (False) 86 | (MatchGroup 87 | [ 88 | (L {HelloWorld.hs:2:0-30} 89 | (Match 90 | [] 91 | (Nothing) 92 | (GRHSs 93 | [ 94 | (L {HelloWorld.hs:2:7-30} 95 | (GRHS 96 | [] 97 | (L {HelloWorld.hs:2:7-30} 98 | (HsApp 99 | (L {HelloWorld.hs:2:7-14} 100 | (HsVar {Name: System.IO.putStrLn})) 101 | (L {HelloWorld.hs:2:16-30} 102 | (HsLit 103 | (HsString {FastString: "Hello, World!"})))))))] 104 | (EmptyLocalBinds))))] {!type placeholder here?!}) 105 | (WpHole) {NameSet: 106 | [{Name: System.IO.putStrLn}]} 107 | (Nothing)))]})] 108 | []) 109 | [] 110 | [] 111 | [] 112 | [] 113 | [] 114 | [] 115 | [] 116 | [] 117 | []) 118 | [ 119 | (L {Implicit import declaration} 120 | (ImportDecl 121 | (L {Implicit import declaration} {ModuleName: Prelude}) 122 | (False) 123 | (False) 124 | (Nothing) 125 | (Nothing)))] 126 | (Nothing) 127 | (Nothing) 128 | (HaddockModInfo 129 | (Nothing) 130 | (Nothing) 131 | (Nothing) 132 | (Nothing))) 133 | ------------------------- shown typecheckedSource 134 | {Bag(Located (HsBind Var)): 135 | [ 136 | (L {HelloWorld.hs:2:0-30} 137 | (AbsBinds 138 | [] 139 | [] 140 | [ 141 | ((,,,) 142 | [] {Var: HelloWorld.main} {Var: main} 143 | [])] {Bag(Located (HsBind Var)): 144 | [ 145 | (L {HelloWorld.hs:2:0-30} 146 | (FunBind 147 | (L {HelloWorld.hs:2:0-3} {Var: main}) 148 | (False) 149 | (MatchGroup 150 | [ 151 | (L {HelloWorld.hs:2:0-30} 152 | (Match 153 | [] 154 | (Nothing) 155 | (GRHSs 156 | [ 157 | (L {HelloWorld.hs:2:7-30} 158 | (GRHS 159 | [] 160 | (L {HelloWorld.hs:2:7-30} 161 | (HsApp 162 | (L {HelloWorld.hs:2:7-14} 163 | (HsVar {Var: System.IO.putStrLn})) 164 | (L {HelloWorld.hs:2:16-30} 165 | (HsLit 166 | (HsString {FastString: "Hello, World!"})))))))] 167 | (EmptyLocalBinds))))] GHC.IOBase.IO ()) 168 | (WpHole) {!NameSet placeholder here!} 169 | (Nothing)))]}))]} 170 | @ 171 | -} 172 | module GHC.SYB.Utils where 173 | 174 | import Data.Generics 175 | 176 | -- import qualified GHC.Paths 177 | import PprTyThing 178 | import DynFlags 179 | import GHC 180 | import Outputable 181 | import SrcLoc 182 | import qualified OccName(occNameString) 183 | import Bag(Bag,bagToList) 184 | import Var(Var) 185 | import FastString(FastString) 186 | import NameSet(NameSet,nameSetToList) 187 | 188 | import GHC.SYB.Instances 189 | import Data.List 190 | 191 | -- | Ghc Ast types tend to have undefined holes, to be filled 192 | -- by later compiler phases. We tag Asts with their source, 193 | -- so that we can avoid such holes based on who generated the Asts. 194 | data Stage = Parser | Renamer | TypeChecker deriving (Eq,Ord,Show) 195 | 196 | -- | Generic Data-based show, with special cases for GHC Ast types, 197 | -- and simplistic indentation-based layout (the 'Int' parameter); 198 | -- showing abstract types abstractly and avoiding known potholes 199 | -- (based on the 'Stage' that generated the Ast) 200 | showData :: Data a => Stage -> Int -> a -> String 201 | showData stage n = 202 | generic `ext1Q` list `extQ` string `extQ` fastString `extQ` srcSpan 203 | `extQ` name `extQ` occName `extQ` moduleName `extQ` var `extQ` dataCon 204 | `extQ` bagName `extQ` bagRdrName `extQ` bagVar `extQ` nameSet 205 | `extQ` postTcType `extQ` fixity 206 | where generic :: Data a => a -> String 207 | generic t = indent n ++ "(" ++ showConstr (toConstr t) 208 | ++ space (concat (intersperse " " (gmapQ (showData stage (n+1)) t))) ++ ")" 209 | space "" = "" 210 | space s = ' ':s 211 | indent n = "\n" ++ replicate n ' ' 212 | string = show :: String -> String 213 | fastString = ("{FastString: "++) . (++"}") . show :: FastString -> String 214 | list l = indent n ++ "[" 215 | ++ concat (intersperse "," (map (showData stage (n+1)) l)) ++ "]" 216 | 217 | name = ("{Name: "++) . (++"}") . showSDoc . ppr :: Name -> String 218 | occName = ("{OccName: "++) . (++"}") . OccName.occNameString 219 | moduleName = ("{ModuleName: "++) . (++"}") . showSDoc . ppr :: ModuleName -> String 220 | srcSpan = ("{"++) . (++"}") . showSDoc . ppr :: SrcSpan -> String 221 | var = ("{Var: "++) . (++"}") . showSDoc . ppr :: Var -> String 222 | dataCon = ("{DataCon: "++) . (++"}") . showSDoc . ppr :: DataCon -> String 223 | 224 | bagRdrName:: Bag (Located (HsBind RdrName)) -> String 225 | bagRdrName = ("{Bag(Located (HsBind RdrName)): "++) . (++"}") . list . bagToList 226 | bagName :: Bag (Located (HsBind Name)) -> String 227 | bagName = ("{Bag(Located (HsBind Name)): "++) . (++"}") . list . bagToList 228 | bagVar :: Bag (Located (HsBind Var)) -> String 229 | bagVar = ("{Bag(Located (HsBind Var)): "++) . (++"}") . list . bagToList 230 | 231 | nameSet | stage `elem` [Parser,TypeChecker] 232 | = const ("{!NameSet placeholder here!}") :: NameSet -> String 233 | | otherwise 234 | = ("{NameSet: "++) . (++"}") . list . nameSetToList 235 | 236 | postTcType | stage String 237 | | otherwise = showSDoc . ppr :: Type -> String 238 | 239 | fixity | stage String 240 | | otherwise = ("{Fixity: "++) . (++"}") . showSDoc . ppr :: GHC.Fixity -> String 241 | 242 | -- | Like 'everything', but avoid known potholes, based on the 'Stage' that 243 | -- generated the Ast. 244 | everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r 245 | everythingStaged stage k z f x 246 | | (const False `extQ` postTcType `extQ` fixity `extQ` nameSet) x = z 247 | | otherwise = foldl k (f x) (gmapQ (everythingStaged stage k z f) x) 248 | where nameSet = const (stage `elem` [Parser,TypeChecker]) :: NameSet -> Bool 249 | postTcType = const (stage Bool 250 | fixity = const (stage Bool 251 | 252 | -- | A variation of 'everything', using a 'GenericQ Bool' to skip 253 | -- parts of the input 'Data'. 254 | everythingBut :: GenericQ Bool -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r 255 | everythingBut q k z f x 256 | | q x = z 257 | | otherwise = foldl k (f x) (gmapQ (everythingBut q k z f) x) 258 | -------------------------------------------------------------------------------- /src/GHC/SYB/Instances.hs: -------------------------------------------------------------------------------- 1 | {- | "GHC.Syb.Instances" provides instances of Data\/Typeable 2 | for Ghc Api types, using standalone deriving. 3 | 4 | Most instances are standard; to provide 'Data' instances 5 | abstract types, we use one of two schemes: 6 | 7 | - no traversal: 'SrcSpan', 'Module', 'ModuleName', 'OccName', 'Name', 8 | 'FastString', 'DataCon', 'Var', 'TyCon', 'Class' 9 | 10 | @ 11 | abstractConstr n = mkConstr (abstractDataType n) ("{abstract:"++n++"}") [] Prefix 12 | abstractDataType n = mkDataType n [abstractConstr n] 13 | @ 14 | 15 | @ 16 | instance Data SrcSpan where 17 | -- don't traverse? 18 | toConstr _ = abstractConstr "SrcSpan" 19 | gunfold _ _ = error "gunfold" 20 | dataTypeOf _ = mkNorepType "SrcSpan" 21 | @ 22 | 23 | - abstract traversal: 'NameSet', 'Bag' 24 | 25 | @ 26 | instance Data NameSet where 27 | gfoldl k z s = z mkNameSet `k` nameSetToList s -- traverse abstractly 28 | toConstr _ = abstractConstr "NameSet" 29 | gunfold _ _ = error "gunfold" 30 | dataTypeOf _ = mkNorepType "NameSet" 31 | @ 32 | 33 | Please report any issues, either with these abstract instances or with 34 | these modules going out of sync with GHC head, to the package maintainer. 35 | 36 | -} 37 | module GHC.SYB.Instances where 38 | 39 | import GHC hiding(TyCon) 40 | import SrcLoc 41 | import RdrName 42 | import OccName 43 | import FastString 44 | import Bag 45 | import Module 46 | import BasicTypes 47 | import Var 48 | import ForeignCall 49 | 50 | import CoreSyn 51 | import Literal 52 | import CostCentre 53 | 54 | import Data.Data 55 | import NameSet 56 | import TypeRep 57 | import qualified TyCon 58 | 59 | #include "Typeable.h" 60 | 61 | #ifdef __HADDOCK__ 62 | #else 63 | 64 | -- TODO: good for generalized show, but is this sound in general? 65 | abstractConstr n = mkConstr (abstractDataType n) ("{abstract:"++n++"}") [] Prefix 66 | abstractDataType n = mkDataType n [abstractConstr n] 67 | 68 | -- Typeable0 69 | 70 | INSTANCE_TYPEABLE0(SrcSpan,srcSpanTc,"SrcSpan") 71 | instance Data SrcSpan where 72 | -- don't traverse? 73 | toConstr _ = abstractConstr "SrcSpan" 74 | gunfold _ _ = error "gunfold" 75 | dataTypeOf _ = mkNorepType "SrcSpan" 76 | 77 | INSTANCE_TYPEABLE0(Module,moduleTc,"Module") 78 | instance Data Module where 79 | -- don't traverse? 80 | toConstr _ = abstractConstr "Module" 81 | gunfold _ _ = error "gunfold" 82 | dataTypeOf _ = mkNorepType "Module" 83 | 84 | INSTANCE_TYPEABLE0(ModuleName,moduleNameTc,"ModuleName") 85 | instance Data ModuleName where 86 | -- don't traverse? 87 | toConstr _ = abstractConstr "ModuleName" 88 | gunfold _ _ = error "gunfold" 89 | dataTypeOf _ = mkNorepType "ModuleName" 90 | 91 | deriving instance Typeable RdrName 92 | deriving instance Data RdrName 93 | 94 | INSTANCE_TYPEABLE0(OccName,occNameTc,"OccName") 95 | instance Data OccName where 96 | -- don't traverse? 97 | toConstr _ = abstractConstr "OccName" 98 | gunfold _ _ = error "gunfold" 99 | dataTypeOf _ = mkNorepType "OccName" 100 | 101 | INSTANCE_TYPEABLE0(Name,nameTc,"Name") 102 | instance Data Name where 103 | -- don't traverse? 104 | toConstr _ = abstractConstr "Name" 105 | gunfold _ _ = error "gunfold" 106 | dataTypeOf _ = mkNorepType "Name" 107 | 108 | deriving instance Typeable FastString 109 | instance Data FastString where 110 | -- don't traverse? 111 | toConstr _ = abstractConstr "FastString" 112 | gunfold _ _ = error "gunfold" 113 | dataTypeOf _ = mkNorepType "FastString" 114 | 115 | deriving instance Typeable HsExplicitForAll 116 | deriving instance Data HsExplicitForAll 117 | 118 | deriving instance Typeable HsBang 119 | deriving instance Data HsBang 120 | 121 | deriving instance Typeable Boxity 122 | deriving instance Data Boxity 123 | 124 | deriving instance Typeable OverLitVal 125 | deriving instance Data OverLitVal 126 | 127 | deriving instance Typeable RecFlag 128 | deriving instance Data RecFlag 129 | 130 | deriving instance Typeable BasicTypes.Fixity 131 | deriving instance Data BasicTypes.Fixity 132 | 133 | deriving instance Typeable HsArrAppType 134 | deriving instance Data HsArrAppType 135 | 136 | deriving instance Typeable FixityDirection 137 | deriving instance Data FixityDirection 138 | 139 | INSTANCE_TYPEABLE0(DataCon,dataConTc,"DataCon") 140 | instance Data DataCon where 141 | -- don't traverse? 142 | toConstr _ = abstractConstr "DataCon" 143 | gunfold _ _ = error "gunfold" 144 | dataTypeOf _ = mkNorepType "DataCon" 145 | 146 | INSTANCE_TYPEABLE0(Var,varTc,"Var") 147 | instance Data Var where 148 | -- don't traverse? 149 | toConstr _ = abstractConstr "Var" 150 | gunfold _ _ = error "gunfold" 151 | dataTypeOf _ = mkNorepType "Var" 152 | 153 | deriving instance Typeable InlineSpec 154 | deriving instance Data InlineSpec 155 | 156 | #ifdef CONSTRUCTOR_LIKE_IDS 157 | deriving instance Typeable InlinePragma 158 | deriving instance Data InlinePragma 159 | 160 | deriving instance Typeable RuleMatchInfo 161 | deriving instance Data RuleMatchInfo 162 | #endif 163 | 164 | deriving instance Typeable ForeignImport 165 | deriving instance Data ForeignImport 166 | 167 | deriving instance Typeable ForeignExport 168 | deriving instance Data ForeignExport 169 | 170 | deriving instance Typeable CImportSpec 171 | deriving instance Data CImportSpec 172 | 173 | deriving instance Typeable CExportSpec 174 | deriving instance Data CExportSpec 175 | 176 | deriving instance Typeable DNCallSpec 177 | deriving instance Data DNCallSpec 178 | 179 | deriving instance Typeable Safety 180 | deriving instance Data Safety 181 | 182 | deriving instance Typeable CCallConv 183 | deriving instance Data CCallConv 184 | 185 | deriving instance Typeable DNKind 186 | deriving instance Data DNKind 187 | 188 | deriving instance Typeable DNType 189 | deriving instance Data DNType 190 | 191 | deriving instance Typeable CCallTarget 192 | deriving instance Data CCallTarget 193 | 194 | deriving instance Typeable Activation 195 | deriving instance Data Activation 196 | 197 | INSTANCE_TYPEABLE0(NameSet,nameSetTc,"NameSet") 198 | instance Data NameSet where 199 | gfoldl k z s = z mkNameSet `k` nameSetToList s -- traverse abstractly 200 | toConstr _ = abstractConstr "NameSet" 201 | gunfold _ _ = error "gunfold" 202 | dataTypeOf _ = mkNorepType "NameSet" 203 | 204 | deriving instance Typeable FoType 205 | deriving instance Data FoType 206 | 207 | deriving instance Typeable FamilyFlavour 208 | deriving instance Data FamilyFlavour 209 | 210 | deriving instance Typeable NewOrData 211 | deriving instance Data NewOrData 212 | 213 | INSTANCE_TYPEABLE0(TyCon.TyCon,tyConTc,"TyCon") 214 | instance Data TyCon.TyCon where 215 | -- don't traverse? 216 | toConstr _ = abstractConstr "TyCon.TyCon" 217 | gunfold _ _ = error "gunfold" 218 | dataTypeOf _ = mkNorepType "TyCon.TyCon" 219 | 220 | INSTANCE_TYPEABLE0(Class,classTc,"Class") 221 | instance Data Class where 222 | -- don't traverse? 223 | toConstr _ = abstractConstr "Class" 224 | gunfold _ _ = error "gunfold" 225 | dataTypeOf _ = mkNorepType "Class" 226 | 227 | deriving instance Typeable Prag 228 | deriving instance Data Prag 229 | 230 | deriving instance Typeable HsWrapper 231 | deriving instance Data HsWrapper 232 | 233 | deriving instance Typeable PredType 234 | deriving instance Data PredType 235 | 236 | deriving instance Typeable Type 237 | deriving instance Data Type 238 | 239 | deriving instance Typeable HsLit 240 | deriving instance Data HsLit 241 | 242 | deriving instance Typeable Note 243 | deriving instance Data Note 244 | 245 | deriving instance Typeable AltCon 246 | deriving instance Data AltCon 247 | 248 | deriving instance Typeable Literal 249 | deriving instance Data Literal 250 | 251 | deriving instance Typeable CostCentre 252 | deriving instance Data CostCentre 253 | 254 | deriving instance Typeable FunctionOrData 255 | deriving instance Data FunctionOrData 256 | 257 | deriving instance Typeable IsDupdCC 258 | deriving instance Data IsDupdCC 259 | 260 | deriving instance Typeable IsCafCC 261 | deriving instance Data IsCafCC 262 | 263 | 264 | -- Typeable1 265 | 266 | deriving instance Typeable1 Located 267 | deriving instance Data e => Data (Located e) 268 | 269 | deriving instance Typeable1 HsModule 270 | deriving instance Data a => Data (HsModule a) 271 | 272 | deriving instance Typeable1 HsDoc 273 | deriving instance Data a => Data (HsDoc a) 274 | 275 | deriving instance Typeable1 HaddockModInfo 276 | deriving instance Data a => Data (HaddockModInfo a) 277 | 278 | deriving instance Typeable1 HsDecl 279 | deriving instance Data a => Data (HsDecl a) 280 | 281 | deriving instance Typeable1 ImportDecl 282 | deriving instance Data a => Data (ImportDecl a) 283 | 284 | deriving instance Typeable1 IE 285 | deriving instance Data a => Data (IE a) 286 | 287 | deriving instance Typeable1 TyClDecl 288 | deriving instance Data a => Data (TyClDecl a) 289 | 290 | deriving instance Typeable1 DocDecl 291 | deriving instance Data a => Data (DocDecl a) 292 | 293 | deriving instance Typeable1 SpliceDecl 294 | deriving instance Data a => Data (SpliceDecl a) 295 | 296 | deriving instance Typeable1 RuleDecl 297 | deriving instance Data a => Data (RuleDecl a) 298 | 299 | deriving instance Typeable WarningTxt 300 | deriving instance Data WarningTxt 301 | 302 | deriving instance Typeable1 WarnDecl 303 | deriving instance Data a => Data (WarnDecl a) 304 | 305 | deriving instance Typeable1 ForeignDecl 306 | deriving instance Data a => Data (ForeignDecl a) 307 | 308 | deriving instance Typeable1 DefaultDecl 309 | deriving instance Data a => Data (DefaultDecl a) 310 | 311 | deriving instance Typeable1 Sig 312 | deriving instance Data a => Data (Sig a) 313 | 314 | deriving instance Typeable1 DerivDecl 315 | deriving instance Data a => Data (DerivDecl a) 316 | 317 | deriving instance Typeable1 InstDecl 318 | deriving instance Data a => Data (InstDecl a) 319 | 320 | deriving instance Typeable1 HsPred 321 | deriving instance Data a => Data (HsPred a) 322 | 323 | deriving instance Typeable1 HsType 324 | deriving instance Data a => Data (HsType a) 325 | 326 | deriving instance Typeable1 ConDecl 327 | deriving instance Data a => Data (ConDecl a) 328 | 329 | INSTANCE_TYPEABLE1(Bag,bagTc,"Bag") 330 | instance Data a => Data (Bag a) where 331 | gfoldl k z b = z listToBag `k` bagToList b -- traverse abstract type abstractly 332 | toConstr _ = abstractConstr $ "Bag("++show (typeOf (undefined::a))++")" 333 | gunfold _ _ = error "gunfold" 334 | dataTypeOf _ = mkNorepType "Bag" 335 | 336 | deriving instance Typeable1 HsTyVarBndr 337 | deriving instance Data a => Data (HsTyVarBndr a) 338 | 339 | deriving instance Typeable1 ResType 340 | deriving instance Data a => Data (ResType a) 341 | 342 | deriving instance Typeable1 HsSplice 343 | deriving instance Data a => Data (HsSplice a) 344 | 345 | deriving instance Typeable1 ConDeclField 346 | deriving instance Data a => Data (ConDeclField a) 347 | 348 | deriving instance Typeable1 IPName 349 | deriving instance Data a => Data (IPName a) 350 | 351 | deriving instance Typeable1 MatchGroup 352 | deriving instance Data a => Data (MatchGroup a) 353 | 354 | deriving instance Typeable1 Pat 355 | deriving instance Data a => Data (Pat a) 356 | 357 | deriving instance Typeable1 GRHSs 358 | deriving instance Data a => Data (GRHSs a) 359 | 360 | deriving instance Typeable1 HsExpr 361 | deriving instance Data a => Data (HsExpr a) 362 | 363 | deriving instance Typeable1 HsQuasiQuote 364 | deriving instance Data a => Data (HsQuasiQuote a) 365 | 366 | deriving instance Typeable1 HsOverLit 367 | deriving instance Data a => Data (HsOverLit a) 368 | 369 | deriving instance Typeable1 ArithSeqInfo 370 | deriving instance Data a => Data (ArithSeqInfo a) 371 | 372 | deriving instance Typeable1 HsBracket 373 | deriving instance Data a => Data (HsBracket a) 374 | 375 | deriving instance Typeable1 HsCmdTop 376 | deriving instance Data a => Data (HsCmdTop a) 377 | 378 | deriving instance Typeable1 HsGroup 379 | deriving instance Data a => Data (HsGroup a) 380 | 381 | deriving instance Typeable1 FixitySig 382 | deriving instance Data a => Data (FixitySig a) 383 | 384 | deriving instance Typeable1 HsIPBinds 385 | deriving instance Data a => Data (HsIPBinds a) 386 | 387 | deriving instance Typeable1 IPBind 388 | deriving instance Data a => Data (IPBind a) 389 | 390 | deriving instance Typeable1 GroupByClause 391 | deriving instance Data a => Data (GroupByClause a) 392 | 393 | deriving instance Typeable1 HsStmtContext 394 | deriving instance Data a => Data (HsStmtContext a) 395 | 396 | deriving instance Typeable1 HsMatchContext 397 | deriving instance Data a => Data (HsMatchContext a) 398 | 399 | deriving instance Typeable1 GRHS 400 | deriving instance Data a => Data (GRHS a) 401 | 402 | deriving instance Typeable1 Match 403 | deriving instance Data a => Data (Match a) 404 | 405 | deriving instance Typeable1 RuleBndr 406 | deriving instance Data a => Data (RuleBndr a) 407 | 408 | deriving instance Typeable1 Bind 409 | deriving instance Data a => Data (Bind a) 410 | 411 | deriving instance Typeable1 Expr 412 | deriving instance Data a => Data (Expr a) 413 | 414 | -- Typeable2 415 | 416 | deriving instance Typeable2 HsBindLR 417 | deriving instance (Data a,Data b) => Data (HsBindLR a b) 418 | 419 | deriving instance Typeable2 StmtLR 420 | deriving instance (Data a,Data b) => Data (StmtLR a b) 421 | 422 | deriving instance Typeable2 HsLocalBindsLR 423 | deriving instance (Data a,Data b) => Data (HsLocalBindsLR a b) 424 | 425 | deriving instance Typeable2 HsValBindsLR 426 | deriving instance (Data a,Data b) => Data (HsValBindsLR a b) 427 | 428 | deriving instance Typeable2 HsConDetails 429 | deriving instance (Data a,Data b) => Data (HsConDetails a b) 430 | 431 | deriving instance Typeable2 HsRecFields 432 | deriving instance (Data a,Data b) => Data (HsRecFields a b) 433 | 434 | deriving instance Typeable2 HsRecField 435 | deriving instance (Data a,Data b) => Data (HsRecField a b) 436 | 437 | #ifdef HAS_ANNOTATIONS 438 | deriving instance Data a => Data (AnnDecl a) 439 | deriving instance Typeable1 AnnDecl 440 | 441 | deriving instance Data a => Data (AnnProvenance a) 442 | deriving instance Typeable1 AnnProvenance 443 | #endif 444 | 445 | #endif 446 | 447 | --------------------------------------------------------------------------------