[project @ 1999-03-24 12:29:05 by kw217]
authorkw217 <unknown>
Wed, 24 Mar 1999 12:29:05 +0000 (12:29 +0000)
committerkw217 <unknown>
Wed, 24 Mar 1999 12:29:05 +0000 (12:29 +0000)
Fix pretty-printing of FunTys to not throw away NoteTys (eg type synonyms).

ghc/compiler/types/PprType.lhs

index 0cf818d..7c2260f 100644 (file)
@@ -19,7 +19,7 @@ module PprType(
 -- friends:
 -- (PprType can see all the representations it's trying to print)
 import Type            ( Type(..), TyNote(..), Kind, ThetaType, 
-                         splitFunTys, splitDictTy_maybe,
+                         splitDictTy_maybe,
                          splitForAllTys, splitSigmaTy, splitRhoTy,
                          isDictTy, splitTyConApp_maybe, splitFunTy_maybe,
                          boxedTypeKind
@@ -180,12 +180,13 @@ ppr_ty env ctxt_prec ty@(ForAllTy _ _)
 
 
 ppr_ty env ctxt_prec (FunTy ty1 ty2)
-    -- We fiddle the precedences passed to left/right branches,
-    -- so that right associativity comes out nicely...
-  = maybeParen ctxt_prec fUN_PREC (sep (ppr_ty env fUN_PREC ty1 : pp_rest))
+  = maybeParen ctxt_prec fUN_PREC (sep (ppr_ty env fUN_PREC ty1 : pp_rest ty2))
+  -- we don't want to lose usage annotations or synonyms,
+  -- so we can't use splitFunTys here.
   where
-    (arg_tys, result_ty) = splitFunTys ty2
-    pp_rest = [ ptext SLIT("-> ") <> ppr_ty env fUN_PREC ty | ty <- arg_tys ++ [result_ty] ]
+    pp_rest (FunTy ty1 ty2) = pp_codom ty1 : pp_rest ty2
+    pp_rest ty              = [pp_codom ty]
+    pp_codom ty             = ptext SLIT("->") <+> ppr_ty env fUN_PREC ty
 
 ppr_ty env ctxt_prec (AppTy ty1 ty2)
   = maybeParen ctxt_prec tYCON_PREC $