diff options
author | David Waern <david.waern@gmail.com> | 2010-03-30 01:10:20 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2010-03-30 01:10:20 +0000 |
commit | f278f0676579f67075033a4f9857715909c4b71e (patch) | |
tree | 70316557d88f261e1af80ebe6c132374e32b7c15 /compiler/hsSyn | |
parent | ef6e8211dee59eb7fa80a242391b89b52bd57f80 (diff) | |
download | haskell-f278f0676579f67075033a4f9857715909c4b71e.tar.gz |
Add Data and Typeable instances to HsSyn
The instances (and deriving declarations) have been taken from the ghc-syb
package.
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r-- | compiler/hsSyn/HsBinds.lhs | 13 | ||||
-rw-r--r-- | compiler/hsSyn/HsDecls.lhs | 26 | ||||
-rw-r--r-- | compiler/hsSyn/HsDoc.hs | 6 | ||||
-rw-r--r-- | compiler/hsSyn/HsExpr.lhs | 20 | ||||
-rw-r--r-- | compiler/hsSyn/HsExpr.lhs-boot | 7 | ||||
-rw-r--r-- | compiler/hsSyn/HsImpExp.lhs | 6 | ||||
-rw-r--r-- | compiler/hsSyn/HsLit.lhs | 7 | ||||
-rw-r--r-- | compiler/hsSyn/HsPat.lhs | 8 | ||||
-rw-r--r-- | compiler/hsSyn/HsPat.lhs-boot | 4 | ||||
-rw-r--r-- | compiler/hsSyn/HsSyn.lhs | 8 | ||||
-rw-r--r-- | compiler/hsSyn/HsTypes.lhs | 13 |
11 files changed, 106 insertions, 12 deletions
diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs index f3648832f3..c4d38fd7a3 100644 --- a/compiler/hsSyn/HsBinds.lhs +++ b/compiler/hsSyn/HsBinds.lhs @@ -13,6 +13,7 @@ Datatype for: @BindGroup@, @Bind@, @Sig@, @Bind@. -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details +{-# LANGUAGE DeriveDataTypeable #-} module HsBinds where @@ -34,6 +35,8 @@ import Util import Var import Bag import FastString + +import Data.Data hiding ( Fixity ) \end{code} %************************************************************************ @@ -58,6 +61,7 @@ data HsLocalBindsLR idL idR -- Bindings in a 'let' expression = HsValBinds (HsValBindsLR idL idR) | HsIPBinds (HsIPBinds idR) | EmptyLocalBinds + deriving (Data, Typeable) type HsValBinds id = HsValBindsLR id id @@ -71,6 +75,7 @@ data HsValBindsLR idL idR -- Value bindings (not implicit parameters) -- in the list may depend on earlier -- ones. [LSig Name] + deriving (Data, Typeable) type LHsBinds id = Bag (LHsBind id) type DictBinds id = LHsBinds id -- Used for dictionary or method bindings @@ -148,6 +153,7 @@ data HsBindLR idL idR -- mixed up together; you can tell the dict bindings because -- they are all VarBinds } + deriving (Data, Typeable) -- Consider (AbsBinds tvs ds [(ftvs, poly_f, mono_f) binds] -- -- Creates bindings for (polymorphic, overloaded) poly_f @@ -317,6 +323,7 @@ data HsIPBinds id [LIPBind id] (DictBinds id) -- Only in typechecker output; binds -- uses of the implicit parameters + deriving (Data, Typeable) isEmptyIPBinds :: HsIPBinds id -> Bool isEmptyIPBinds (IPBinds is ds) = null is && isEmptyBag ds @@ -328,6 +335,7 @@ data IPBind id = IPBind (IPName id) (LHsExpr id) + deriving (Data, Typeable) instance (OutputableBndr id) => Outputable (HsIPBinds id) where ppr (IPBinds bs ds) = pprDeeperList vcat (map ppr bs) @@ -370,6 +378,7 @@ data HsWrapper -- is always exactly WpHole | WpLet (LHsBinds Id) -- let binds in [] -- (would be nicer to be core bindings) + deriving (Data, Typeable) instance Outputable HsWrapper where ppr co_fn = pprHsWrapper (ptext (sLit "<>")) co_fn @@ -466,21 +475,25 @@ data Sig name -- Signatures and pragmas -- {-# SPECIALISE instance Eq [Int] #-} | SpecInstSig (LHsType name) -- (Class tys); should be a specialisation of the -- current instance decl + deriving (Data, Typeable) type LFixitySig name = Located (FixitySig name) data FixitySig name = FixitySig (Located name) Fixity + deriving (Data, Typeable) -- TsSpecPrags conveys pragmas from the type checker to the desugarer data TcSpecPrags = IsDefaultMethod -- Super-specialised: a default method should -- be macro-expanded at every call site | SpecPrags [Located TcSpecPrag] + deriving (Data, Typeable) data TcSpecPrag = SpecPrag HsWrapper -- An wrapper, that specialises the polymorphic function InlinePragma -- Inlining spec for the specialised function + deriving (Data, Typeable) noSpecPrags :: TcSpecPrags noSpecPrags = SpecPrags [] diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs index 08d12b7f37..0038ebed0a 100644 --- a/compiler/hsSyn/HsDecls.lhs +++ b/compiler/hsSyn/HsDecls.lhs @@ -12,6 +12,7 @@ -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details +{-# LANGUAGE DeriveDataTypeable #-} -- | Abstract syntax of global declarations. -- @@ -76,6 +77,7 @@ import SrcLoc import FastString import Control.Monad ( liftM ) +import Data.Data import Data.Maybe ( isJust ) \end{code} @@ -103,6 +105,7 @@ data HsDecl id | SpliceD (SpliceDecl id) | DocD (DocDecl) | QuasiQuoteD (HsQuasiQuote id) + deriving (Data, Typeable) -- NB: all top-level fixity decls are contained EITHER @@ -138,7 +141,7 @@ data HsGroup id hs_ruleds :: [LRuleDecl id], hs_docs :: [LDocDecl] - } + } deriving (Data, Typeable) emptyGroup, emptyRdrGroup, emptyRnGroup :: HsGroup a emptyRdrGroup = emptyGroup { hs_valds = emptyValBindsIn } @@ -230,6 +233,7 @@ instance OutputableBndr name => Outputable (HsGroup name) where ppr_ds ds = blankLine $$ vcat (map ppr ds) data SpliceDecl id = SpliceDecl (Located (HsExpr id)) -- Top level splice + deriving (Data, Typeable) instance OutputableBndr name => Outputable (SpliceDecl name) where ppr (SpliceDecl e) = ptext (sLit "$") <> parens (pprExpr (unLoc e)) @@ -480,15 +484,17 @@ data TyClDecl name -- latter for defaults tcdDocs :: [LDocDecl] -- ^ Haddock docs } + deriving (Data, Typeable) data NewOrData = NewType -- ^ @newtype Blah ...@ | DataType -- ^ @data Blah ...@ - deriving( Eq ) -- Needed because Demand derives Eq + deriving( Eq, Data, Typeable ) -- Needed because Demand derives Eq data FamilyFlavour = TypeFamily -- ^ @type family ...@ | DataFamily -- ^ @data family ...@ + deriving (Data, Typeable) \end{code} Simple classifiers @@ -726,7 +732,7 @@ data ConDecl name -- GADT-style record decl C { blah } :: T a b -- Remove this when we no longer parse this stuff, and hence do not -- need to report decprecated use - } + } deriving (Data, Typeable) type HsConDeclDetails name = HsConDetails (LBangType name) [ConDeclField name] @@ -739,6 +745,7 @@ data ResType name = ResTyH98 -- Constructor was declared using Haskell 98 syntax | ResTyGADT (LHsType name) -- Constructor was declared using GADT-style syntax, -- and here is its result type + deriving (Data, Typeable) instance OutputableBndr name => Outputable (ResType name) where -- Debugging only @@ -814,6 +821,7 @@ data InstDecl name [LSig name] -- User-supplied pragmatic info [LTyClDecl name]-- Associated types (ie, 'TyData' and -- 'TySynonym' only) + deriving (Data, Typeable) instance (OutputableBndr name) => Outputable (InstDecl name) where @@ -839,6 +847,7 @@ instDeclATs (InstDecl _ _ _ ats) = ats type LDerivDecl name = Located (DerivDecl name) data DerivDecl name = DerivDecl (LHsType name) + deriving (Data, Typeable) instance (OutputableBndr name) => Outputable (DerivDecl name) where ppr (DerivDecl ty) @@ -860,6 +869,7 @@ type LDefaultDecl name = Located (DefaultDecl name) data DefaultDecl name = DefaultDecl [LHsType name] + deriving (Data, Typeable) instance (OutputableBndr name) => Outputable (DefaultDecl name) where @@ -887,6 +897,7 @@ type LForeignDecl name = Located (ForeignDecl name) data ForeignDecl name = ForeignImport (Located name) (LHsType name) ForeignImport -- defines name | ForeignExport (Located name) (LHsType name) ForeignExport -- uses name + deriving (Data, Typeable) -- Specification Of an imported external entity in dependence on the calling -- convention @@ -909,6 +920,7 @@ data ForeignImport = -- import of a C entity Safety -- safe or unsafe FastString -- name of C header CImportSpec -- details of the C entity + deriving (Data, Typeable) -- details of an external C entity -- @@ -916,11 +928,13 @@ data CImportSpec = CLabel CLabelString -- import address of a C label | CFunction CCallTarget -- static or dynamic function | CWrapper -- wrapper to expose closures -- (former f.e.d.) + deriving (Data, Typeable) -- specification of an externally exported entity in dependence on the calling -- convention -- data ForeignExport = CExport CExportSpec -- contains the calling convention + deriving (Data, Typeable) -- pretty printing of foreign declarations -- @@ -972,10 +986,12 @@ data RuleDecl name NameSet -- Free-vars from the LHS (Located (HsExpr name)) -- RHS NameSet -- Free-vars from the RHS + deriving (Data, Typeable) data RuleBndr name = RuleBndr (Located name) | RuleBndrSig (Located name) (LHsType name) + deriving (Data, Typeable) collectRuleBndrSigTys :: [RuleBndr name] -> [LHsType name] collectRuleBndrSigTys bndrs = [ty | RuleBndrSig _ ty <- bndrs] @@ -1009,6 +1025,7 @@ data DocDecl | DocCommentPrev HsDocString | DocCommentNamed String HsDocString | DocGroup Int HsDocString + deriving (Data, Typeable) -- Okay, I need to reconstruct the document comments, but for now: instance Outputable DocDecl where @@ -1034,6 +1051,7 @@ We use exported entities for things to deprecate. type LWarnDecl name = Located (WarnDecl name) data WarnDecl name = Warning name WarningTxt + deriving (Data, Typeable) instance OutputableBndr name => Outputable (WarnDecl name) where ppr (Warning thing txt) @@ -1050,6 +1068,7 @@ instance OutputableBndr name => Outputable (WarnDecl name) where type LAnnDecl name = Located (AnnDecl name) data AnnDecl name = HsAnnotation (AnnProvenance name) (Located (HsExpr name)) + deriving (Data, Typeable) instance (OutputableBndr name) => Outputable (AnnDecl name) where ppr (HsAnnotation provenance expr) @@ -1059,6 +1078,7 @@ instance (OutputableBndr name) => Outputable (AnnDecl name) where data AnnProvenance name = ValueAnnProvenance name | TypeAnnProvenance name | ModuleAnnProvenance + deriving (Data, Typeable) annProvenanceName_maybe :: AnnProvenance name -> Maybe name annProvenanceName_maybe (ValueAnnProvenance name) = Just name diff --git a/compiler/hsSyn/HsDoc.hs b/compiler/hsSyn/HsDoc.hs index d8e5b677fb..1f3adafec1 100644 --- a/compiler/hsSyn/HsDoc.hs +++ b/compiler/hsSyn/HsDoc.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DeriveDataTypeable #-} + module HsDoc ( HsDocString(..), LHsDocString, @@ -10,8 +12,10 @@ import Outputable import SrcLoc import FastString +import Data.Data + newtype HsDocString = HsDocString FastString - deriving (Eq, Show) + deriving (Eq, Show, Data, Typeable) type LHsDocString = Located HsDocString diff --git a/compiler/hsSyn/HsExpr.lhs b/compiler/hsSyn/HsExpr.lhs index bde737a253..7930caa00d 100644 --- a/compiler/hsSyn/HsExpr.lhs +++ b/compiler/hsSyn/HsExpr.lhs @@ -3,6 +3,7 @@ % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % \begin{code} +{-# LANGUAGE DeriveDataTypeable #-} -- | Abstract Haskell syntax for expressions. module HsExpr where @@ -24,6 +25,9 @@ import DataCon import SrcLoc import Outputable import FastString + +-- libraries: +import Data.Data hiding (Fixity) \end{code} @@ -275,6 +279,7 @@ data HsExpr id | HsWrap HsWrapper -- TRANSLATION (HsExpr id) + deriving (Data, Typeable) -- HsTupArg is used for tuple sections -- (,a,) is represented by ExplicitTuple [Mising ty1, Present a, Missing ty3] @@ -282,6 +287,7 @@ data HsExpr id data HsTupArg id = Present (LHsExpr id) -- The argument | Missing PostTcType -- The argument is missing, but this is its type + deriving (Data, Typeable) tupArgPresent :: HsTupArg id -> Bool tupArgPresent (Present {}) = True @@ -587,6 +593,7 @@ type HsCmd id = HsExpr id type LHsCmd id = LHsExpr id data HsArrAppType = HsHigherOrderApp | HsFirstOrderApp + deriving (Data, Typeable) \end{code} The legal constructors for commands are: @@ -640,6 +647,7 @@ data HsCmdTop id PostTcType -- return type of the command (SyntaxTable id) -- after type checking: -- names used in the command's desugaring + deriving (Data, Typeable) \end{code} %************************************************************************ @@ -681,6 +689,7 @@ data MatchGroup id PostTcType -- The type is the type of the entire group -- t1 -> ... -> tn -> tr -- where there are n patterns + deriving (Data, Typeable) type LMatch id = Located (Match id) @@ -690,6 +699,7 @@ data Match id (Maybe (LHsType id)) -- A type signature for the result of the match -- Nothing after typechecking (GRHSs id) + deriving (Data, Typeable) isEmptyMatchGroup :: MatchGroup id -> Bool isEmptyMatchGroup (MatchGroup ms _) = null ms @@ -712,13 +722,14 @@ data GRHSs id = GRHSs { grhssGRHSs :: [LGRHS id], -- ^ Guarded RHSs grhssLocalBinds :: (HsLocalBinds id) -- ^ The where clause - } + } deriving (Data, Typeable) type LGRHS id = Located (GRHS id) -- | Guarded Right Hand Side. data GRHS id = GRHS [LStmt id] -- Guards (LHsExpr id) -- Right hand side + deriving (Data, Typeable) \end{code} We know the list must have at least one @Match@ in it. @@ -887,6 +898,7 @@ data StmtLR idL idR , recS_dicts :: DictBinds idR -- Method bindings of Ids bound by the -- RecStmt, and used afterwards } + deriving (Data, Typeable) \end{code} Note [GroupStmt binder map] @@ -1047,6 +1059,7 @@ pprComp quals body -- Prints: body | qual1, ..., qualn data HsSplice id = HsSplice -- $z or $(f 4) id -- The id is just a unique name to (LHsExpr id) -- identify this splice point + deriving (Data, Typeable) instance OutputableBndr id => Outputable (HsSplice id) where ppr = pprSplice @@ -1062,6 +1075,7 @@ data HsBracket id = ExpBr (LHsExpr id) -- [| expr |] | DecBrG (HsGroup id) -- [d| decls |]; result of renamer | TypBr (LHsType id) -- [t| type |] | VarBr id -- 'x, ''T + deriving (Data, Typeable) instance OutputableBndr id => Outputable (HsBracket id) where ppr = pprHsBracket @@ -1100,6 +1114,7 @@ data ArithSeqInfo id | FromThenTo (LHsExpr id) (LHsExpr id) (LHsExpr id) + deriving (Data, Typeable) \end{code} \begin{code} @@ -1133,7 +1148,7 @@ data HsMatchContext id -- Context of a Match -- runtime error message to generate] | StmtCtxt (HsStmtContext id) -- Pattern of a do-stmt or list comprehension | ThPatQuote -- A Template Haskell pattern quotation [p| (a,b) |] - deriving () + deriving (Data, Typeable) data HsStmtContext id = ListComp @@ -1146,6 +1161,7 @@ data HsStmtContext id | PatGuard (HsMatchContext id) -- Pattern guard for specified thing | ParStmtCtxt (HsStmtContext id) -- A branch of a parallel stmt | TransformStmtCtxt (HsStmtContext id) -- A branch of a transform stmt + deriving (Data, Typeable) \end{code} \begin{code} diff --git a/compiler/hsSyn/HsExpr.lhs-boot b/compiler/hsSyn/HsExpr.lhs-boot index e0b4d047e7..272bdbd6a8 100644 --- a/compiler/hsSyn/HsExpr.lhs-boot +++ b/compiler/hsSyn/HsExpr.lhs-boot @@ -4,12 +4,19 @@ module HsExpr where import SrcLoc ( Located ) import Outputable ( SDoc, OutputableBndr ) import {-# SOURCE #-} HsPat ( LPat ) + +import Data.Data data HsExpr i data HsSplice i data MatchGroup a data GRHSs a +instance Data i => Data (HsSplice i) +instance Data i => Data (HsExpr i) +instance Data i => Data (MatchGroup i) +instance Data i => Data (GRHSs i) + type LHsExpr a = Located (HsExpr a) type SyntaxExpr a = HsExpr a diff --git a/compiler/hsSyn/HsImpExp.lhs b/compiler/hsSyn/HsImpExp.lhs index 5870176278..dd24aedb2b 100644 --- a/compiler/hsSyn/HsImpExp.lhs +++ b/compiler/hsSyn/HsImpExp.lhs @@ -12,6 +12,7 @@ HsImpExp: Abstract syntax: imports, exports, interfaces -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details +{-# LANGUAGE DeriveDataTypeable #-} module HsImpExp where @@ -21,6 +22,8 @@ import HsDoc ( HsDocString ) import Outputable import FastString import SrcLoc ( Located(..) ) + +import Data.Data \end{code} %************************************************************************ @@ -42,7 +45,7 @@ data ImportDecl name ideclQualified :: Bool, -- ^ True => qualified ideclAs :: Maybe ModuleName, -- ^ as Module ideclHiding :: Maybe (Bool, [LIE name]) -- ^ (True => hiding, names) - } + } deriving (Data, Typeable) \end{code} \begin{code} @@ -91,6 +94,7 @@ data IE name | IEGroup Int HsDocString -- ^ Doc section heading | IEDoc HsDocString -- ^ Some documentation | IEDocNamed String -- ^ Reference to named doc + deriving (Data, Typeable) \end{code} \begin{code} diff --git a/compiler/hsSyn/HsLit.lhs b/compiler/hsSyn/HsLit.lhs index 9a0e8750e6..0874dda858 100644 --- a/compiler/hsSyn/HsLit.lhs +++ b/compiler/hsSyn/HsLit.lhs @@ -5,6 +5,8 @@ \section[HsLit]{Abstract syntax: source-language literals} \begin{code} +{-# LANGUAGE DeriveDataTypeable #-} + module HsLit where #include "HsVersions.h" @@ -14,6 +16,8 @@ import HsTypes (PostTcType) import Type ( Type ) import Outputable import FastString + +import Data.Data \end{code} @@ -40,6 +44,7 @@ data HsLit -- (overloaded literals are done with HsOverLit) | HsFloatPrim Rational -- Unboxed Float | HsDoublePrim Rational -- Unboxed Double + deriving (Data, Typeable) instance Eq HsLit where (HsChar x1) == (HsChar x2) = x1==x2 @@ -62,11 +67,13 @@ data HsOverLit id -- An overloaded literal -- False <=> standard syntax ol_witness :: SyntaxExpr id, -- Note [Overloaded literal witnesses] ol_type :: PostTcType } + deriving (Data, Typeable) data OverLitVal = HsIntegral !Integer -- Integer-looking literals; | HsFractional !Rational -- Frac-looking literals | HsIsString !FastString -- String-looking literals + deriving (Data, Typeable) overLitType :: HsOverLit a -> Type overLitType = ol_type diff --git a/compiler/hsSyn/HsPat.lhs b/compiler/hsSyn/HsPat.lhs index 8ab583a28c..c025a8dc35 100644 --- a/compiler/hsSyn/HsPat.lhs +++ b/compiler/hsSyn/HsPat.lhs @@ -11,6 +11,7 @@ -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details +{-# LANGUAGE DeriveDataTypeable #-} module HsPat ( Pat(..), InPat, OutPat, LPat, @@ -46,6 +47,8 @@ import Outputable import Type import SrcLoc import FastString +-- libraries: +import Data.Data hiding (TyCon) \end{code} @@ -151,6 +154,7 @@ data Pat id Type -- Type of whole pattern, t1 -- During desugaring a (CoPat co pat) turns into a cast with 'co' on -- the scrutinee, followed by a match on 'pat' + deriving (Data, Typeable) \end{code} HsConDetails is use for patterns/expressions *and* for data type declarations @@ -160,6 +164,7 @@ data HsConDetails arg rec = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } | InfixCon arg arg -- p1 `C` p2 + deriving (Data, Typeable) type HsConPatDetails id = HsConDetails (LPat id) (HsRecFields id (LPat id)) @@ -178,6 +183,7 @@ data HsRecFields id arg -- A bunch of record fields -- Used for both expressions and patterns = HsRecFields { rec_flds :: [HsRecField id arg], rec_dotdot :: Maybe Int } -- Note [DotDot fields] + deriving (Data, Typeable) -- Note [DotDot fields] -- ~~~~~~~~~~~~~~~~~~~~ @@ -197,7 +203,7 @@ data HsRecField id arg = HsRecField { hsRecFieldId :: Located id, hsRecFieldArg :: arg, -- Filled in by renamer hsRecPun :: Bool -- Note [Punning] - } + } deriving (Data, Typeable) -- Note [Punning] -- ~~~~~~~~~~~~~~ diff --git a/compiler/hsSyn/HsPat.lhs-boot b/compiler/hsSyn/HsPat.lhs-boot index d5b685c1f1..5a8726fab9 100644 --- a/compiler/hsSyn/HsPat.lhs-boot +++ b/compiler/hsSyn/HsPat.lhs-boot @@ -2,6 +2,10 @@ module HsPat where import SrcLoc( Located ) +import Data.Data + data Pat i type LPat i = Located (Pat i) + +instance Data i => Data (Pat i) \end{code} diff --git a/compiler/hsSyn/HsSyn.lhs b/compiler/hsSyn/HsSyn.lhs index 1365e1dbae..39093f2550 100644 --- a/compiler/hsSyn/HsSyn.lhs +++ b/compiler/hsSyn/HsSyn.lhs @@ -9,6 +9,8 @@ which is declared in the various \tr{Hs*} modules. This module, therefore, is almost nothing but re-exporting. \begin{code} +{-# LANGUAGE DeriveDataTypeable #-} + module HsSyn ( module HsBinds, module HsDecls, @@ -42,6 +44,9 @@ import Outputable import SrcLoc ( Located(..) ) import Module ( Module, ModuleName ) import FastString + +-- libraries: +import Data.Data hiding ( Fixity ) \end{code} \begin{code} @@ -70,8 +75,7 @@ data HsModule name -- ^ reason\/explanation for warning/deprecation of this module hsmodHaddockModHeader :: Maybe LHsDocString -- ^ Haddock module info and description, unparsed - } - + } deriving (Data, Typeable) data HsExtCore name -- Read from Foo.hcr = HsExtCore diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs index 2e2eaabccf..9b3930531e 100644 --- a/compiler/hsSyn/HsTypes.lhs +++ b/compiler/hsSyn/HsTypes.lhs @@ -6,6 +6,8 @@ HsTypes: Abstract syntax: user-defined types \begin{code} +{-# LANGUAGE DeriveDataTypeable #-} + module HsTypes ( HsType(..), LHsType, HsTyVarBndr(..), LHsTyVarBndr, @@ -42,6 +44,8 @@ import SrcLoc import StaticFlags import Outputable import FastString + +import Data.Data \end{code} @@ -76,6 +80,7 @@ data HsQuasiQuote id = HsQuasiQuote id -- The quasi-quoter SrcSpan -- The span of the enclosed string FastString -- The enclosed string + deriving (Data, Typeable) instance OutputableBndr id => Outputable (HsQuasiQuote id) where ppr = ppr_qq @@ -101,6 +106,7 @@ data HsBang = HsNoBang -- Only used as a return value for getBangStrictness, -- never appears on a HsBangTy | HsStrict -- ! | HsUnbox -- {-# UNPACK #-} ! (GHC extension, meaning "unbox") + deriving (Data, Typeable) instance Outputable HsBang where ppr (HsNoBang) = empty @@ -135,6 +141,7 @@ type LHsPred name = Located (HsPred name) data HsPred name = HsClassP name [LHsType name] -- class constraint | HsEqualP (LHsType name) (LHsType name)-- equality constraint | HsIParam (IPName name) (LHsType name) + deriving (Data, Typeable) type LHsType name = Located (HsType name) @@ -194,14 +201,15 @@ data HsType name | HsBangTy HsBang (LHsType name) -- Bang-style type annotations | HsRecTy [ConDeclField name] -- Only in data type declarations + deriving (Data, Typeable) -data HsExplicitFlag = Explicit | Implicit +data HsExplicitFlag = Explicit | Implicit deriving (Data, Typeable) data ConDeclField name -- Record fields have Haddoc docs on them = ConDeclField { cd_fld_name :: Located name, cd_fld_type :: LBangType name, cd_fld_doc :: Maybe LHsDocString } - + deriving (Data, Typeable) ----------------------- -- Combine adjacent for-alls. @@ -257,6 +265,7 @@ data HsTyVarBndr name -- *** NOTA BENE *** A "monotype" in a pragma can have -- for-alls in it, (mostly to do with dictionaries). These -- must be explicitly Kinded. + deriving (Data, Typeable) hsTyVarName :: HsTyVarBndr name -> name hsTyVarName (UserTyVar n _) = n |