GhcApiAstTraversals: Instances0.hs

File Instances0.hs, 4.8 KB (added by claus, 6 years ago)

derived instances Data/Typeable?, part1

Line 
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE TypeSynonymInstances #-}
3{-# LANGUAGE StandaloneDeriving #-}
4{-# LANGUAGE DeriveDataTypeable #-}
5
6module Instances0 where
7
8import GHC hiding(TyCon)
9import SrcLoc
10import RdrName
11import OccName
12import FastString
13import Bag
14import Module
15import BasicTypes
16import Var
17import ForeignCall
18
19import Data.Generics
20import NameSet
21import TypeRep
22import qualified TyCon
23
24#include "Typeable.h"
25
26-- TODO: good for generalized show, but is this sound in general?
27abstractConstr   n = mkConstr (abstractDataType n) ("{abstract:"++n++"}") [] Prefix
28abstractDataType n = mkDataType n [abstractConstr n]
29
30-- Typeable
31
32INSTANCE_TYPEABLE0(SrcSpan,srcSpanTc,"SrcSpan")
33instance Data SrcSpan where
34  -- don't traverse?
35  toConstr _   = abstractConstr "SrcSpan"
36  gunfold _ _  = error "gunfold"
37  dataTypeOf _ = mkNorepType "SrcSpan"
38
39INSTANCE_TYPEABLE0(Module,moduleTc,"Module")
40instance Data Module where
41  -- don't traverse?
42  toConstr _   = abstractConstr "Module"
43  gunfold _ _  = error "gunfold"
44  dataTypeOf _ = mkNorepType "Module"
45
46INSTANCE_TYPEABLE0(ModuleName,moduleNameTc,"ModuleName")
47instance Data ModuleName where
48  -- don't traverse?
49  toConstr _   = abstractConstr "ModuleName"
50  gunfold _ _  = error "gunfold"
51  dataTypeOf _ = mkNorepType "ModuleName"
52
53deriving instance Typeable RdrName
54deriving instance Data RdrName
55
56INSTANCE_TYPEABLE0(OccName,occNameTc,"OccName")
57instance Data OccName where
58  -- don't traverse?
59  toConstr _   = abstractConstr "OccName"
60  gunfold _ _  = error "gunfold"
61  dataTypeOf _ = mkNorepType "OccName"
62
63INSTANCE_TYPEABLE0(Name,nameTc,"Name")
64instance Data Name where
65  -- don't traverse?
66  toConstr _   = abstractConstr "Name"
67  gunfold _ _  = error "gunfold"
68  dataTypeOf _ = mkNorepType "Name"
69
70deriving instance Typeable FastString
71instance Data FastString where
72  -- don't traverse?
73  toConstr _   = abstractConstr "FastString"
74  gunfold _ _  = error "gunfold"
75  dataTypeOf _ = mkNorepType "FastString"
76
77deriving instance Typeable HsExplicitForAll
78deriving instance Data HsExplicitForAll
79
80deriving instance Typeable HsBang
81deriving instance Data HsBang
82
83deriving instance Typeable Boxity
84deriving instance Data Boxity
85
86deriving instance Typeable OverLitVal
87deriving instance Data OverLitVal
88
89deriving instance Typeable RecFlag
90deriving instance Data RecFlag
91
92deriving instance Typeable BasicTypes.Fixity
93deriving instance Data BasicTypes.Fixity
94
95deriving instance Typeable HsArrAppType
96deriving instance Data HsArrAppType
97
98deriving instance Typeable FixityDirection
99deriving instance Data FixityDirection
100
101INSTANCE_TYPEABLE0(DataCon,dataConTc,"DataCon")
102instance Data DataCon where
103  -- don't traverse?
104  toConstr _   = abstractConstr "DataCon"
105  gunfold _ _  = error "gunfold"
106  dataTypeOf _ = mkNorepType "DataCon"
107
108INSTANCE_TYPEABLE0(Var,varTc,"Var")
109instance Data Var where
110  -- don't traverse?
111  toConstr _   = abstractConstr "Var"
112  gunfold _ _  = error "gunfold"
113  dataTypeOf _ = mkNorepType "Var"
114
115deriving instance Typeable InlineSpec
116deriving instance Data InlineSpec
117
118deriving instance Typeable ForeignImport
119deriving instance Data ForeignImport
120
121deriving instance Typeable ForeignExport
122deriving instance Data ForeignExport
123
124deriving instance Typeable CImportSpec
125deriving instance Data CImportSpec
126
127deriving instance Typeable CExportSpec
128deriving instance Data CExportSpec
129
130deriving instance Typeable DNCallSpec
131deriving instance Data DNCallSpec
132
133deriving instance Typeable Safety
134deriving instance Data Safety
135
136deriving instance Typeable CCallConv
137deriving instance Data CCallConv
138
139deriving instance Typeable DNKind
140deriving instance Data DNKind
141
142deriving instance Typeable DNType
143deriving instance Data DNType
144
145deriving instance Typeable CCallTarget
146deriving instance Data CCallTarget
147
148deriving instance Typeable Activation
149deriving instance Data Activation
150
151INSTANCE_TYPEABLE0(NameSet,nameSetTc,"NameSet")
152instance Data NameSet where
153  gfoldl k z s = z mkNameSet `k` nameSetToList s -- traverse abstractly
154  toConstr _   = abstractConstr "NameSet"
155  gunfold _ _  = error "gunfold"
156  dataTypeOf _ = mkNorepType "NameSet"
157
158deriving instance Typeable FoType
159deriving instance Data FoType
160
161deriving instance Typeable FamilyFlavour
162deriving instance Data FamilyFlavour
163
164deriving instance Typeable NewOrData
165deriving instance Data NewOrData
166
167INSTANCE_TYPEABLE0(TyCon.TyCon,tyConTc,"TyCon")
168instance Data TyCon.TyCon where
169  toConstr _   = abstractConstr "TyCon.TyCon"
170  gunfold _ _  = error "gunfold"
171  dataTypeOf _ = mkNorepType "TyCon.TyCon"
172
173INSTANCE_TYPEABLE0(Class,classTc,"Class")
174instance Data Class where
175  toConstr _   = abstractConstr "Class"
176  gunfold _ _  = error "gunfold"
177  dataTypeOf _ = mkNorepType "Class"
178
179