X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FHsTypes.lhs;h=d565c96d29da4f6e089cac236b6288045ae055a8;hb=c1c2c25355bc462e521b2c5fb41ac79307da22ff;hp=a5e89828265f0913f91f9f3369b204198c82b0da;hpb=1a9245caefb80a3c4c5965aaacdf9a607e792e1c;p=ghc-hetmet.git diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs index a5e8982..d565c96 100644 --- a/compiler/hsSyn/HsTypes.lhs +++ b/compiler/hsSyn/HsTypes.lhs @@ -26,6 +26,7 @@ module HsTypes ( hsTyVarKind, hsTyVarNameKind, hsLTyVarName, hsLTyVarNames, hsLTyVarLocName, hsLTyVarLocNames, splitHsInstDeclTy, splitHsFunType, + splitHsAppTys, mkHsAppTys, -- Type place holder PostTcType, placeHolderType, PostTcKind, placeHolderKind, @@ -168,8 +169,6 @@ 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 -- ^^^^ @@ -294,6 +293,19 @@ replaceTyVarName (KindedTyVar _ k) n' = KindedTyVar n' k \begin{code} +splitHsAppTys :: LHsType n -> [LHsType n] -> (LHsType n, [LHsType n]) +splitHsAppTys (L _ (HsAppTy f a)) as = splitHsAppTys f (a:as) +splitHsAppTys f as = (f,as) + +mkHsAppTys :: OutputableBndr n => LHsType n -> [LHsType n] -> HsType n +mkHsAppTys fun_ty [] = pprPanic "mkHsAppTys" (ppr fun_ty) +mkHsAppTys fun_ty (arg_ty:arg_tys) + = foldl mk_app (HsAppTy fun_ty arg_ty) arg_tys + where + mk_app fun arg = HsAppTy (noLoc fun) arg + -- Add noLocs for inner nodes of the application; + -- they are never used + splitHsInstDeclTy :: OutputableBndr name => HsType name @@ -359,8 +371,8 @@ pprHsForAll exp tvs cxt pprHsContext :: (OutputableBndr name) => HsContext name -> SDoc pprHsContext [] = empty pprHsContext [L _ pred] - | noParenHsPred pred = ppr pred <+> ptext (sLit "=>") -pprHsContext cxt = ppr_hs_context cxt <+> ptext (sLit "=>") + | noParenHsPred pred = ppr pred <+> darrow +pprHsContext cxt = ppr_hs_context cxt <+> darrow noParenHsPred :: HsPred name -> Bool -- c.f. TypeRep.noParenPred @@ -440,7 +452,6 @@ 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