X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FhsSyn%2FHsTypes.lhs;h=7dbb16df64b82608b0762aebbf9ca76e615f3d63;hp=9b3930531e199835a286f372d3a66c97a7f6265a;hb=0af06ed99ed56341adfdda4a92a0a36678780109;hpb=f278f0676579f67075033a4f9857715909c4b71e diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs index 9b39305..7dbb16d 100644 --- a/compiler/hsSyn/HsTypes.lhs +++ b/compiler/hsSyn/HsTypes.lhs @@ -102,17 +102,6 @@ ppr_qq (HsQuasiQuote quoter _ quote) = type LBangType name = Located (BangType name) type BangType name = HsType name -- Bangs are in the HsType data type -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 - ppr (HsStrict) = char '!' - ppr (HsUnbox) = ptext (sLit "!!") - getBangType :: LHsType a -> LHsType a getBangType (L _ (HsBangTy _ ty)) = ty getBangType ty = ty @@ -179,14 +168,12 @@ data HsType name -- interface files smaller), so when printing a HsType we may need to -- add parens. - | HsNumTy Integer -- Generics only - | HsPredTy (HsPred name) -- Only used in the type of an instance -- declaration, eg. Eq [a] -> Eq a -- ^^^^ -- HsPredTy -- Note no need for location info on the - -- enclosed HsPred; the one on the type will do + -- Enclosed HsPred; the one on the type will do | HsKindSig (LHsType name) -- (ty :: kind) Kind -- A type with a kind signature @@ -201,6 +188,10 @@ data HsType name | HsBangTy HsBang (LHsType name) -- Bang-style type annotations | HsRecTy [ConDeclField name] -- Only in data type declarations + + | HsCoreTy Type -- An escape hatch for tunnelling a *closed* + -- Core Type through HsSyn. + deriving (Data, Typeable) data HsExplicitFlag = Explicit | Implicit deriving (Data, Typeable) @@ -364,8 +355,16 @@ pprHsForAll exp tvs cxt forall_part = ptext (sLit "forall") <+> interppSP tvs <> dot pprHsContext :: (OutputableBndr name) => HsContext name -> SDoc -pprHsContext [] = empty -pprHsContext cxt = ppr_hs_context cxt <+> ptext (sLit "=>") +pprHsContext [] = empty +pprHsContext [L _ pred] + | noParenHsPred pred = ppr pred <+> darrow +pprHsContext cxt = ppr_hs_context cxt <+> darrow + +noParenHsPred :: HsPred name -> Bool +-- c.f. TypeRep.noParenPred +noParenHsPred (HsClassP {}) = True +noParenHsPred (HsEqualP {}) = True +noParenHsPred (HsIParam {}) = False ppr_hs_context :: (OutputableBndr name) => HsContext name -> SDoc ppr_hs_context [] = empty @@ -439,8 +438,8 @@ ppr_mono_ty _ (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcol 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 _ (HsCoreTy ty) = ppr ty ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) = maybeParen ctxt_prec pREC_CON $