X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FhsSyn%2FHsDecls.lhs;h=4b1b028a78ba13d787be56533d37f4a21778df0a;hb=23f40f0e9be6d4aa5cf9ea31d73f4013f8e7b4bd;hp=3a610024a35beb222102eb33d60697775c9a52eb;hpb=9b6858cb53438a2651ab00202582b13f95036058;p=ghc-hetmet.git diff --git a/ghc/compiler/hsSyn/HsDecls.lhs b/ghc/compiler/hsSyn/HsDecls.lhs index 3a61002..4b1b028 100644 --- a/ghc/compiler/hsSyn/HsDecls.lhs +++ b/ghc/compiler/hsSyn/HsDecls.lhs @@ -14,9 +14,7 @@ module HsDecls ( DefaultDecl(..), LDefaultDecl, HsGroup(..), SpliceDecl(..), ForeignDecl(..), LForeignDecl, ForeignImport(..), ForeignExport(..), CImportSpec(..), FoType(..), - ConDecl(..), LConDecl, - LBangType, BangType(..), HsBang(..), - getBangType, getBangStrictness, unbangedType, + ConDecl(..), LConDecl, DeprecDecl(..), LDeprecDecl, tcdName, tyClDeclNames, tyClDeclTyVars, isClassDecl, isSynDecl, isDataDecl, @@ -429,7 +427,10 @@ pp_decl_head :: OutputableBndr name pp_decl_head context thing tyvars = hsep [pprHsContext context, ppr thing, interppSP tyvars] -pp_condecls cs = equals <+> sep (punctuate (ptext SLIT(" |")) (map ppr cs)) +pp_condecls cs@(L _ (GadtDecl _ _) : _) -- In GADT syntax + = hang (ptext SLIT("where")) 2 (vcat (map ppr cs)) +pp_condecls cs -- In H98 syntax + = equals <+> sep (punctuate (ptext SLIT(" |")) (map ppr cs)) pp_tydecl pp_head pp_decl_rhs derivings = hang pp_head 4 (sep [ @@ -461,8 +462,12 @@ data ConDecl name [LHsTyVarBndr name] -- Existentially quantified type variables (LHsContext name) -- ...and context -- If both are empty then there are no existentials - (HsConDetails name (LBangType name)) + + | GadtDecl (Located name) -- Constructor name; this is used for the + -- DataCon itself, and for the user-callable wrapper Id + (LHsType name) -- Constructor type; it may have HsBangs on the + -- argument types \end{code} \begin{code} @@ -481,32 +486,23 @@ conDeclsNames cons do_one (flds_seen, acc) (ConDecl lname _ _ _) = (flds_seen, lname:acc) +-- gaw 2004 + do_one (flds_seen, acc) (GadtDecl lname _) + = (flds_seen, lname:acc) + conDetailsTys details = map getBangType (hsConArgs details) \end{code} -\begin{code} -type LBangType name = Located (BangType name) - -data BangType name = BangType HsBang (LHsType name) - -data HsBang = HsNoBang - | HsStrict -- ! - | HsUnbox -- {-# UNPACK #-} ! (GHC extension, meaning "unbox") - -getBangType (BangType _ ty) = ty -getBangStrictness (BangType s _) = s - -unbangedType :: LHsType id -> LBangType id -unbangedType ty@(L loc _) = L loc (BangType HsNoBang ty) -\end{code} \begin{code} instance (OutputableBndr name) => Outputable (ConDecl name) where ppr (ConDecl con tvs cxt con_details) = sep [pprHsForAll Explicit tvs cxt, ppr_con_details con con_details] + ppr (GadtDecl con ty) + = ppr con <+> dcolon <+> ppr ty ppr_con_details con (InfixCon ty1 ty2) - = hsep [ppr ty1, ppr con, ppr ty2] + = hsep [ppr ty1, pprHsVar con, ppr ty2] -- ConDecls generated by MkIface.ifaceTyThing always have a PrefixCon, even -- if the constructor is an infix one. This is because in an interface file @@ -520,17 +516,8 @@ ppr_con_details con (RecCon fields) where ppr_field (n, ty) = ppr n <+> dcolon <+> ppr ty -instance OutputableBndr name => Outputable (BangType name) where - ppr (BangType is_strict ty) - = bang <> pprParendHsType (unLoc ty) - where - bang = case is_strict of - HsNoBang -> empty - HsStrict -> char '!' - HsUnbox -> ptext SLIT("!!") \end{code} - %************************************************************************ %* * \subsection[InstDecl]{An instance declaration