X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FHsTypes.lhs;h=797a8f28eaec8d315ec74c8f51d05c356ef149ca;hb=c7517d84fe15a202029d5a77dfaf51c87e7e7234;hp=7d91a4233af1574fccd77335784dab183e2c1f23;hpb=e5cc0e3da51641157cbec8989ccc709f989b730c;p=ghc-hetmet.git diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs index 7d91a42..797a8f2 100644 --- a/compiler/hsSyn/HsTypes.lhs +++ b/compiler/hsSyn/HsTypes.lhs @@ -15,6 +15,8 @@ module HsTypes ( LBangType, BangType, HsBang(..), getBangType, getBangStrictness, + + ConDeclField(..), pprConDeclFields, mkExplicitHsForAllTy, mkImplicitHsForAllTy, hsExplicitTvs, hsTyVarName, hsTyVarNames, replaceTyVarName, @@ -118,8 +120,6 @@ data HsType name | HsTyVar name -- Type variable or type constructor - | HsBangTy HsBang (LHsType name) -- Bang-style type annotations - | HsAppTy (LHsType name) (LHsType name) @@ -157,10 +157,24 @@ data HsType name | HsSpliceTy (HsSplice name) - | HsDocTy (LHsType name) (LHsDoc name) -- A documented type + | HsDocTy (LHsType name) LHsDocString -- A documented type + + | HsSpliceTyOut Kind -- Used just like KindedTyVar, just between + -- kcHsType and dsHsType + + | HsBangTy HsBang (LHsType name) -- Bang-style type annotations + | HsRecTy [ConDeclField name] -- Only in data type declarations data HsExplicitForAll = Explicit | Implicit + + +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 } + + ----------------------- -- Combine adjacent for-alls. -- The following awkward situation can happen otherwise: @@ -310,6 +324,13 @@ pprHsContext cxt = ppr_hs_context cxt <+> ptext (sLit "=>") ppr_hs_context :: (OutputableBndr name) => HsContext name -> SDoc ppr_hs_context [] = empty ppr_hs_context cxt = parens (interpp'SP cxt) + +pprConDeclFields :: OutputableBndr name => [ConDeclField name] -> SDoc +pprConDeclFields fields = braces (sep (punctuate comma (map ppr_fld fields))) + where + ppr_fld (ConDeclField { cd_fld_name = n, cd_fld_type = ty, + cd_fld_doc = doc }) + = ppr n <+> dcolon <+> ppr ty <+> ppr_mbDoc doc \end{code} \begin{code} @@ -351,16 +372,18 @@ ppr_mono_ty ctxt_prec (HsForAllTy exp tvs ctxt ty) = maybeParen ctxt_prec pREC_FUN $ sep [pprHsForAll exp tvs ctxt, ppr_mono_lty pREC_TOP ty] -ppr_mono_ty _ (HsBangTy b ty) = ppr b <> ppr ty -ppr_mono_ty _ (HsTyVar name) = ppr name -ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2) = ppr_fun_ty ctxt_prec ty1 ty2 -ppr_mono_ty _ (HsTupleTy con tys) = tupleParens con (interpp'SP tys) -ppr_mono_ty _ (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcolon <+> pprKind kind) -ppr_mono_ty _ (HsListTy ty) = brackets (ppr_mono_lty pREC_TOP ty) -ppr_mono_ty _ (HsPArrTy ty) = pabrackets (ppr_mono_lty pREC_TOP ty) -ppr_mono_ty _ (HsPredTy pred) = ppr pred -ppr_mono_ty _ (HsNumTy n) = integer n -- generics only -ppr_mono_ty _ (HsSpliceTy s) = pprSplice s +ppr_mono_ty _ (HsBangTy b ty) = ppr b <> ppr ty +ppr_mono_ty _ (HsRecTy flds) = pprConDeclFields flds +ppr_mono_ty _ (HsTyVar name) = ppr name +ppr_mono_ty prec (HsFunTy ty1 ty2) = ppr_fun_ty prec ty1 ty2 +ppr_mono_ty _ (HsTupleTy con tys) = tupleParens con (interpp'SP tys) +ppr_mono_ty _ (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcolon <+> pprKind kind) +ppr_mono_ty _ (HsListTy ty) = brackets (ppr_mono_lty pREC_TOP ty) +ppr_mono_ty _ (HsPArrTy ty) = pabrackets (ppr_mono_lty pREC_TOP ty) +ppr_mono_ty _ (HsPredTy pred) = ppr pred +ppr_mono_ty _ (HsNumTy n) = integer n -- generics only +ppr_mono_ty _ (HsSpliceTy s) = pprSplice s +ppr_mono_ty _ (HsSpliceTyOut k) = text "" <> dcolon <> ppr k ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) = maybeParen ctxt_prec pREC_CON $