\begin{code}
module HsDecls (
HsDecl(..), TyClDecl(..), InstDecl(..), RuleDecl(..), RuleBndr(..),
- DefaultDecl(..), HsGroup(..),
+ DefaultDecl(..), HsGroup(..), SpliceDecl(..),
ForeignDecl(..), ForeignImport(..), ForeignExport(..),
CImportSpec(..), FoType(..),
ConDecl(..), CoreDecl(..),
tyClDeclName, tyClDeclNames, tyClDeclTyVars,
isClassDecl, isSynDecl, isDataDecl, isIfaceSigDecl,
isTypeOrClassDecl, countTyClDecls,
- isSourceInstDecl, ifaceRuleDeclName,
+ isSourceInstDecl, instDeclDFun, ifaceRuleDeclName,
conDetailsTys,
collectRuleBndrSigTys, isSrcRule
) where
| DeprecD (DeprecDecl id)
| RuleD (RuleDecl id)
| CoreD (CoreDecl id)
- | SpliceD (HsExpr id) -- Top level splice
+ | SpliceD (SpliceDecl id)
-- NB: all top-level fixity decls are contained EITHER
-- EITHER SigDs
ppr (RuleD rd) = ppr rd
ppr (DeprecD dd) = ppr dd
ppr (CoreD dd) = ppr dd
- ppr (SpliceD e) = ptext SLIT("splice") <> parens (pprExpr e)
+ ppr (SpliceD dd) = ppr dd
instance OutputableBndr name => Outputable (HsGroup name) where
ppr (HsGroup { hs_valds = val_decls,
where
ppr_ds [] = empty
ppr_ds ds = text "" $$ vcat (map ppr ds)
+
+data SpliceDecl id = SpliceDecl (HsExpr id) SrcLoc -- Top level splice
+
+instance OutputableBndr name => Outputable (SpliceDecl name) where
+ ppr (SpliceDecl e _) = ptext SLIT("$") <> parens (pprExpr e)
\end{code}
have (Just binds) in the tcdMeths field, whereas interface decls have Nothing.
In *source-code* class declarations:
+
- When parsing, every ClassOpSig gets a DefMeth with a suitable RdrName
This is done by RdrHsSyn.mkClassOpSigDM
isSourceInstDecl :: InstDecl name -> Bool
isSourceInstDecl (InstDecl _ _ _ maybe_dfun _) = isNothing maybe_dfun
+
+instDeclDFun :: InstDecl name -> Maybe name
+instDeclDFun (InstDecl _ _ _ df _) = df -- A Maybe, but that's ok
\end{code}
\begin{code}
name -- Head of LHS
CoreRule
+isSrcRule :: RuleDecl name -> Bool
isSrcRule (HsRule _ _ _ _ _ _) = True
isSrcRule other = False