Fix printing of splices; part of #4124
[ghc-hetmet.git] / compiler / hsSyn / HsTypes.lhs
index 9b39305..806faf2 100644 (file)
@@ -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
@@ -364,8 +353,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 <+> ptext (sLit "=>")
+pprHsContext cxt        = ppr_hs_context cxt <+> ptext (sLit "=>")
+
+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