summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-06-19 09:01:51 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-06-20 08:16:44 +0100
commit0ceb84e9668ba05d9a0ec49046ad7b4c2557a484 (patch)
tree427d783e2701a7565a1728c6aeb4ba8df548ca55
parentb6693d3096c810b925af1899b45867482bcc81cf (diff)
downloadhaskell-0ceb84e9668ba05d9a0ec49046ad7b4c2557a484.tar.gz
Tidy up the printing of single-predicate contexts
This covers things like Eq a => blah and (?x::Int) => blah where there is just one predicate. Previously we used an ad-hoc test to decide whether to parenthesise it, but acutally there is a much simpler solution: just use the existing precedence mechamism. This applies both to Type and HsType.
-rw-r--r--compiler/hsSyn/HsTypes.lhs81
-rw-r--r--compiler/types/Type.lhs10
-rw-r--r--compiler/types/Type.lhs-boot1
-rw-r--r--compiler/types/TypeRep.lhs50
-rw-r--r--testsuite/tests/deSugar/should_compile/T2431.stderr2
-rw-r--r--testsuite/tests/ghci/scripts/Defer02.stderr4
-rw-r--r--testsuite/tests/ghci/scripts/T2766.stdout2
-rw-r--r--testsuite/tests/haddock/haddock_examples/haddock.Test.stderr2
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr2
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr2
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr4
-rw-r--r--testsuite/tests/indexed-types/should_fail/NoMatchErr.stderr2
-rw-r--r--testsuite/tests/indexed-types/should_fail/T1900.stderr2
-rw-r--r--testsuite/tests/perf/compiler/T5837.stderr2
-rw-r--r--testsuite/tests/polykinds/T7278.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/ContextStack2.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T7609.stderr20
-rw-r--r--testsuite/tests/typecheck/should_fail/T7778.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T8392a.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T8806.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail032.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail058.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail215.stderr2
23 files changed, 97 insertions, 107 deletions
diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs
index 7b7c7574b2..08a0eef498 100644
--- a/compiler/hsSyn/HsTypes.lhs
+++ b/compiler/hsSyn/HsTypes.lhs
@@ -35,7 +35,7 @@ module HsTypes (
splitHsAppTys, hsTyGetAppHead_maybe, mkHsAppTys, mkHsOpTy,
-- Printing
- pprParendHsType, pprHsForAll, pprHsContext, pprHsContextNoArrow, ppr_hs_context,
+ pprParendHsType, pprHsForAll, pprHsContext, pprHsContextNoArrow,
) where
import {-# SOURCE #-} HsExpr ( HsSplice, pprUntypedSplice )
@@ -575,12 +575,8 @@ pprHsContext cxt = pprHsContextNoArrow cxt <+> darrow
pprHsContextNoArrow :: (OutputableBndr name) => HsContext name -> SDoc
pprHsContextNoArrow [] = empty
-pprHsContextNoArrow [L _ pred] = ppr pred
-pprHsContextNoArrow cxt = ppr_hs_context cxt
-
-ppr_hs_context :: (OutputableBndr name) => HsContext name -> SDoc
-ppr_hs_context [] = empty
-ppr_hs_context cxt = parens (interpp'SP cxt)
+pprHsContextNoArrow [L _ pred] = ppr_mono_ty FunPrec pred
+pprHsContextNoArrow cxt = parens (interpp'SP cxt)
pprConDeclFields :: OutputableBndr name => [ConDeclField name] -> SDoc
pprConDeclFields fields = braces (sep (punctuate comma (map ppr_fld fields)))
@@ -602,27 +598,12 @@ and the problem doesn't show up; but having the flag on a KindedTyVar
seems like the Right Thing anyway.)
\begin{code}
-pREC_TOP, pREC_FUN, pREC_OP, pREC_CON :: Int
-pREC_TOP = 0 -- type in ParseIface.y
-pREC_FUN = 1 -- btype in ParseIface.y
- -- Used for LH arg of (->)
-pREC_OP = 2 -- Used for arg of any infix operator
- -- (we don't keep their fixities around)
-pREC_CON = 3 -- Used for arg of type applicn:
- -- always parenthesise unless atomic
-
-maybeParen :: Int -- Precedence of context
- -> Int -- Precedence of top-level operator
- -> SDoc -> SDoc -- Wrap in parens if (ctxt >= op)
-maybeParen ctxt_prec op_prec p | ctxt_prec >= op_prec = parens p
- | otherwise = p
-
--- printing works more-or-less as for Types
+-- Printing works more-or-less as for Types
pprHsType, pprParendHsType :: (OutputableBndr name) => HsType name -> SDoc
-pprHsType ty = getPprStyle $ \sty -> ppr_mono_ty pREC_TOP (prepare sty ty)
-pprParendHsType ty = ppr_mono_ty pREC_CON ty
+pprHsType ty = getPprStyle $ \sty -> ppr_mono_ty TopPrec (prepare sty ty)
+pprParendHsType ty = ppr_mono_ty TyConPrec ty
-- Before printing a type
-- (a) Remove outermost HsParTy parens
@@ -632,15 +613,15 @@ prepare :: PprStyle -> HsType name -> HsType name
prepare sty (HsParTy ty) = prepare sty (unLoc ty)
prepare _ ty = ty
-ppr_mono_lty :: (OutputableBndr name) => Int -> LHsType name -> SDoc
+ppr_mono_lty :: (OutputableBndr name) => TyPrec -> LHsType name -> SDoc
ppr_mono_lty ctxt_prec ty = ppr_mono_ty ctxt_prec (unLoc ty)
-ppr_mono_ty :: (OutputableBndr name) => Int -> HsType name -> SDoc
+ppr_mono_ty :: (OutputableBndr name) => TyPrec -> HsType name -> SDoc
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]
+ = maybeParen ctxt_prec FunPrec $
+ sep [pprHsForAll exp tvs ctxt, ppr_mono_lty TopPrec ty]
-ppr_mono_ty _ (HsBangTy b ty) = ppr b <> ppr_mono_lty pREC_CON ty
+ppr_mono_ty _ (HsBangTy b ty) = ppr b <> ppr_mono_lty TyConPrec ty
ppr_mono_ty _ (HsQuasiQuoteTy qq) = ppr qq
ppr_mono_ty _ (HsRecTy flds) = pprConDeclFields flds
ppr_mono_ty _ (HsTyVar name) = pprPrefixOcc name
@@ -649,10 +630,10 @@ ppr_mono_ty _ (HsTupleTy con tys) = tupleParens std_con (interpp'SP tys)
where std_con = case con of
HsUnboxedTuple -> UnboxedTuple
_ -> BoxedTuple
-ppr_mono_ty _ (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcolon <+> ppr 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 prec (HsIParamTy n ty) = maybeParen prec pREC_FUN (ppr n <+> dcolon <+> ppr_mono_lty pREC_TOP ty)
+ppr_mono_ty _ (HsKindSig ty kind) = parens (ppr_mono_lty TopPrec ty <+> dcolon <+> ppr kind)
+ppr_mono_ty _ (HsListTy ty) = brackets (ppr_mono_lty TopPrec ty)
+ppr_mono_ty _ (HsPArrTy ty) = paBrackets (ppr_mono_lty TopPrec ty)
+ppr_mono_ty prec (HsIParamTy n ty) = maybeParen prec FunPrec (ppr n <+> dcolon <+> ppr_mono_lty TopPrec ty)
ppr_mono_ty _ (HsSpliceTy s _) = pprUntypedSplice s
ppr_mono_ty _ (HsCoreTy ty) = ppr ty
ppr_mono_ty _ (HsExplicitListTy _ tys) = quote $ brackets (interpp'SP tys)
@@ -668,45 +649,45 @@ ppr_mono_ty ctxt_prec (HsWrapTy (WpKiApps _kis) ty)
where
go ctxt_prec [] ty = ppr_mono_ty ctxt_prec ty
go ctxt_prec (ki:kis) ty
- = maybeParen ctxt_prec pREC_CON $
- hsep [ go pREC_FUN kis ty
+ = maybeParen ctxt_prec TyConPrec $
+ hsep [ go FunPrec kis ty
, ptext (sLit "@") <> pprParendKind ki ]
-}
ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2)
- = maybeParen ctxt_prec pREC_OP $
- ppr_mono_lty pREC_OP ty1 <+> char '~' <+> ppr_mono_lty pREC_OP ty2
+ = maybeParen ctxt_prec TyOpPrec $
+ ppr_mono_lty TyOpPrec ty1 <+> char '~' <+> ppr_mono_lty TyOpPrec ty2
ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty)
- = maybeParen ctxt_prec pREC_CON $
- hsep [ppr_mono_lty pREC_FUN fun_ty, ppr_mono_lty pREC_CON arg_ty]
+ = maybeParen ctxt_prec TyConPrec $
+ hsep [ppr_mono_lty FunPrec fun_ty, ppr_mono_lty TyConPrec arg_ty]
ppr_mono_ty ctxt_prec (HsOpTy ty1 (_wrapper, L _ op) ty2)
- = maybeParen ctxt_prec pREC_OP $
- sep [ ppr_mono_lty pREC_OP ty1
- , sep [pprInfixOcc op, ppr_mono_lty pREC_OP ty2 ] ]
+ = maybeParen ctxt_prec TyOpPrec $
+ sep [ ppr_mono_lty TyOpPrec ty1
+ , sep [pprInfixOcc op, ppr_mono_lty TyOpPrec ty2 ] ]
-- Don't print the wrapper (= kind applications)
-- c.f. HsWrapTy
ppr_mono_ty _ (HsParTy ty)
- = parens (ppr_mono_lty pREC_TOP ty)
+ = parens (ppr_mono_lty TopPrec ty)
-- Put the parens in where the user did
-- But we still use the precedence stuff to add parens because
-- toHsType doesn't put in any HsParTys, so we may still need them
ppr_mono_ty ctxt_prec (HsDocTy ty doc)
- = maybeParen ctxt_prec pREC_OP $
- ppr_mono_lty pREC_OP ty <+> ppr (unLoc doc)
+ = maybeParen ctxt_prec TyOpPrec $
+ ppr_mono_lty TyOpPrec ty <+> ppr (unLoc doc)
-- we pretty print Haddock comments on types as if they were
-- postfix operators
--------------------------
-ppr_fun_ty :: (OutputableBndr name) => Int -> LHsType name -> LHsType name -> SDoc
+ppr_fun_ty :: (OutputableBndr name) => TyPrec -> LHsType name -> LHsType name -> SDoc
ppr_fun_ty ctxt_prec ty1 ty2
- = let p1 = ppr_mono_lty pREC_FUN ty1
- p2 = ppr_mono_lty pREC_TOP ty2
+ = let p1 = ppr_mono_lty FunPrec ty1
+ p2 = ppr_mono_lty TopPrec ty2
in
- maybeParen ctxt_prec pREC_FUN $
+ maybeParen ctxt_prec FunPrec $
sep [p1, ptext (sLit "->") <+> p2]
--------------------------
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs
index 0e93c9699f..808216f2ef 100644
--- a/compiler/types/Type.lhs
+++ b/compiler/types/Type.lhs
@@ -51,7 +51,7 @@ module Type (
isDictLikeTy,
mkEqPred, mkCoerciblePred, mkPrimEqPred, mkReprPrimEqPred,
mkClassPred,
- noParenPred, isClassPred, isEqPred,
+ isClassPred, isEqPred,
isIPPred, isIPPred_maybe, isIPTyCon, isIPClass,
-- Deconstructing predicate types
@@ -132,6 +132,7 @@ module Type (
pprTvBndr, pprTvBndrs, pprForAll, pprUserForAll, pprSigmaType,
pprTheta, pprThetaArrowTy, pprClassPred,
pprKind, pprParendKind, pprSourceTyCon,
+ TyPrec(..), maybeParen,
-- * Tidying type related things up for printing
tidyType, tidyTypes,
@@ -833,13 +834,6 @@ applyTysD doc orig_fun_ty arg_tys
Predicates on PredType
\begin{code}
-noParenPred :: PredType -> Bool
--- A predicate that can appear without parens before a "=>"
--- C a => a -> a
--- a~b => a -> b
--- But (?x::Int) => Int -> Int
-noParenPred p = not (isIPPred p) && isClassPred p || isEqPred p
-
isPredTy :: Type -> Bool
-- NB: isPredTy is used when printing types, which can happen in debug printing
-- during type checking of not-fully-zonked types. So it's not cool to say
diff --git a/compiler/types/Type.lhs-boot b/compiler/types/Type.lhs-boot
index c2d2dec093..ff9db3e28c 100644
--- a/compiler/types/Type.lhs-boot
+++ b/compiler/types/Type.lhs-boot
@@ -3,7 +3,6 @@ module Type where
import {-# SOURCE #-} TypeRep( Type, Kind )
import Var
-noParenPred :: Type -> Bool
isPredTy :: Type -> Bool
typeKind :: Type -> Kind
diff --git a/compiler/types/TypeRep.lhs b/compiler/types/TypeRep.lhs
index c93a653310..c8b20e8d93 100644
--- a/compiler/types/TypeRep.lhs
+++ b/compiler/types/TypeRep.lhs
@@ -66,7 +66,7 @@ module TypeRep (
import {-# SOURCE #-} DataCon( dataConTyCon )
import ConLike ( ConLike(..) )
-import {-# SOURCE #-} Type( noParenPred, isPredTy ) -- Transitively pulls in a LOT of stuff, better to break the loop
+import {-# SOURCE #-} Type( isPredTy ) -- Transitively pulls in a LOT of stuff, better to break the loop
-- friends:
import Var
@@ -491,11 +491,29 @@ defined to use this. @pprParendType@ is the same, except it puts
parens around the type, except for the atomic cases. @pprParendType@
works just by setting the initial context precedence very high.
+Note [Precedence in types]
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+We don't keep the fixity of type operators in the operator. So the pretty printer
+operates the following precedene structre:
+ Type constructor application binds more tightly than
+ Oerator applications which bind more tightly than
+ Function arrow
+
+So we might see a :+: T b -> c
+meaning (a :+: (T b)) -> c
+
+Maybe operator applications should bind a bit less tightly?
+
+Anyway, that's the current story, and it is used consistently for Type and HsType
+
\begin{code}
-data TyPrec = TopPrec -- No parens
- | FunPrec -- Function args; no parens for tycon apps
- | TyConPrec -- Tycon args; no parens for atomic
- deriving( Eq, Ord )
+data TyPrec -- See Note [Prededence in types]
+
+ = TopPrec -- No parens
+ | FunPrec -- Function args; no parens for tycon apps
+ | TyOpPrec -- Infix operator
+ | TyConPrec -- Tycon args; no parens for atomic
+ deriving( Eq, Ord )
maybeParen :: TyPrec -> TyPrec -> SDoc -> SDoc
maybeParen ctxt_prec inner_prec pretty
@@ -524,10 +542,9 @@ pprTheta :: ThetaType -> SDoc
pprTheta theta = parens (sep (punctuate comma (map (ppr_type TopPrec) theta)))
pprThetaArrowTy :: ThetaType -> SDoc
-pprThetaArrowTy [] = empty
-pprThetaArrowTy [pred]
- | noParenPred pred = ppr_type TopPrec pred <+> darrow
-pprThetaArrowTy preds = parens (fsep (punctuate comma (map (ppr_type TopPrec) preds)))
+pprThetaArrowTy [] = empty
+pprThetaArrowTy [pred] = ppr_type FunPrec pred <+> darrow
+pprThetaArrowTy preds = parens (fsep (punctuate comma (map (ppr_type TopPrec) preds)))
<+> darrow
-- Notice 'fsep' here rather that 'sep', so that
-- type contexts don't get displayed in a giant column
@@ -563,13 +580,7 @@ instance Outputable TyLit where
ppr_type :: TyPrec -> Type -> SDoc
ppr_type _ (TyVarTy tv) = ppr_tvar tv
-
-ppr_type _ (TyConApp tc [LitTy (StrTyLit n),ty])
- | tc `hasKey` ipClassNameKey
- = char '?' <> ftext n <> ptext (sLit "::") <> ppr_type TopPrec ty
-
ppr_type p (TyConApp tc tys) = pprTyTcApp p tc tys
-
ppr_type p (LitTy l) = ppr_tylit p l
ppr_type p ty@(ForAllTy {}) = ppr_forall_type p ty
@@ -696,6 +707,11 @@ pprTyTcApp :: TyPrec -> TyCon -> [Type] -> SDoc
-- Used for types only; so that we can make a
-- special case for type-level lists
pprTyTcApp p tc tys
+ | tc `hasKey` ipClassNameKey
+ , [LitTy (StrTyLit n),ty] <- tys
+ = maybeParen p FunPrec $
+ char '?' <> ftext n <> ptext (sLit "::") <> ppr_type TopPrec ty
+
| tc `hasKey` consDataConKey
, [_kind,ty1,ty2] <- tys
= sdocWithDynFlags $ \dflags ->
@@ -788,8 +804,8 @@ pprTyList p ty1 ty2
----------------
pprInfixApp :: TyPrec -> (TyPrec -> a -> SDoc) -> SDoc -> a -> a -> SDoc
pprInfixApp p pp pp_tc ty1 ty2
- = maybeParen p FunPrec $
- sep [pp FunPrec ty1, pprInfixVar True pp_tc <+> pp FunPrec ty2]
+ = maybeParen p TyOpPrec $
+ sep [pp TyOpPrec ty1, pprInfixVar True pp_tc <+> pp TyOpPrec ty2]
pprPrefixApp :: TyPrec -> SDoc -> [SDoc] -> SDoc
pprPrefixApp p pp_fun pp_tys
diff --git a/testsuite/tests/deSugar/should_compile/T2431.stderr b/testsuite/tests/deSugar/should_compile/T2431.stderr
index dbafaedf82..c40b603d3f 100644
--- a/testsuite/tests/deSugar/should_compile/T2431.stderr
+++ b/testsuite/tests/deSugar/should_compile/T2431.stderr
@@ -13,7 +13,7 @@ T2431.$WRefl [InlPrag=INLINE] :: forall a. a T2431.:~: a
T2431.$WRefl = \ (@ a) -> T2431.Refl @ a @ a @~ <a>_N
T2431.absurd
- :: forall a. (GHC.Types.Int T2431.:~: GHC.Types.Bool) -> a
+ :: forall a. GHC.Types.Int T2431.:~: GHC.Types.Bool -> a
[GblId, Arity=1, Caf=NoCafRefs, Str=DmdType <L,U>b]
T2431.absurd =
\ (@ a) (x :: GHC.Types.Int T2431.:~: GHC.Types.Bool) ->
diff --git a/testsuite/tests/ghci/scripts/Defer02.stderr b/testsuite/tests/ghci/scripts/Defer02.stderr
index ed36a3eb3c..7635c8f804 100644
--- a/testsuite/tests/ghci/scripts/Defer02.stderr
+++ b/testsuite/tests/ghci/scripts/Defer02.stderr
@@ -84,13 +84,13 @@
the type signature for k :: Int ~ Bool => Int -> Bool
In the ambiguity check for: Int ~ Bool => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature for ‘k’: k :: Int ~ Bool => Int -> Bool
+ In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
../../typecheck/should_run/Defer01.hs:45:6: Warning:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the ambiguity check for: Int ~ Bool => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature for ‘k’: k :: Int ~ Bool => Int -> Bool
+ In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
../../typecheck/should_run/Defer01.hs:45:6: Warning:
Couldn't match type ‘Int’ with ‘Bool’
diff --git a/testsuite/tests/ghci/scripts/T2766.stdout b/testsuite/tests/ghci/scripts/T2766.stdout
index f8ee42ff6a..5bcbd9e75e 100644
--- a/testsuite/tests/ghci/scripts/T2766.stdout
+++ b/testsuite/tests/ghci/scripts/T2766.stdout
@@ -1,3 +1,3 @@
first :: Arrow to => b `to` c -> (b, d) `to` (c, d)
:: Arrow to => to b c -> to (b, d) (c, d)
-first :: b~>c -> (b, d)~>(c, d) :: (b ~> c) -> (b, d) ~> (c, d)
+first :: b~>c -> (b, d)~>(c, d) :: b ~> c -> (b, d) ~> (c, d)
diff --git a/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr b/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
index fa92d3dd92..7ce82d0067 100644
--- a/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
+++ b/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
@@ -85,7 +85,7 @@ newtype N5 a b
newtype N6 a b = docs on the constructor only N6 {n6 :: a b}
<document comment>
newtype N7 a b = The 'N7' constructor N7 {n7 :: a b}
-class D a => C a where
+class (D a) => C a where
a :: IO a
b :: [a]
c :: a
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr
index 6d803bb440..2bb1a178e0 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr
@@ -1,7 +1,7 @@
==================== Parser ====================
module ShouldCompile where
-test :: Eq a => [a] doc1 -> [a] doc2 -> [a] doc3
+test :: (Eq a) => [a] doc1 -> [a] doc2 -> [a] doc3
test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr
index 3e3cb12d10..4a57879c5c 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr
@@ -1,7 +1,7 @@
==================== Parser ====================
module ShouldCompile where
-test :: Eq a => [a] doc1 -> forall b. [b] doc2 -> [a] doc3
+test :: (Eq a) => [a] doc1 -> forall b. [b] doc2 -> [a] doc3
test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr
index 10e88d2bfc..d1cb709c55 100644
--- a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr
@@ -3,8 +3,8 @@
module ShouldCompile where
test ::
[a] doc1
- -> forall b. Ord b =>
- [b] doc2 -> forall c. Num c => [c] doc3 -> [a]
+ -> forall b. (Ord b) =>
+ [b] doc2 -> forall c. (Num c) => [c] doc3 -> [a]
test xs ys zs = xs
diff --git a/testsuite/tests/indexed-types/should_fail/NoMatchErr.stderr b/testsuite/tests/indexed-types/should_fail/NoMatchErr.stderr
index 1ff540979b..d3193d5f30 100644
--- a/testsuite/tests/indexed-types/should_fail/NoMatchErr.stderr
+++ b/testsuite/tests/indexed-types/should_fail/NoMatchErr.stderr
@@ -11,4 +11,4 @@ NoMatchErr.hs:19:7:
In the ambiguity check for:
forall d a. Fun d => Memo d a -> Memo d a
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
- In the type signature for ‘f’: f :: Fun d => Memo d a -> Memo d a
+ In the type signature for ‘f’: f :: (Fun d) => Memo d a -> Memo d a
diff --git a/testsuite/tests/indexed-types/should_fail/T1900.stderr b/testsuite/tests/indexed-types/should_fail/T1900.stderr
index 435d5e8312..d44b4ed210 100644
--- a/testsuite/tests/indexed-types/should_fail/T1900.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T1900.stderr
@@ -11,4 +11,4 @@ T1900.hs:13:10:
In the ambiguity check for: forall s. Bug s => Depend s -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘check’:
- check :: Bug s => Depend s -> Bool
+ check :: (Bug s) => Depend s -> Bool
diff --git a/testsuite/tests/perf/compiler/T5837.stderr b/testsuite/tests/perf/compiler/T5837.stderr
index 2d2907d3ae..5cee13dd1d 100644
--- a/testsuite/tests/perf/compiler/T5837.stderr
+++ b/testsuite/tests/perf/compiler/T5837.stderr
@@ -158,4 +158,4 @@ T5837.hs:8:6:
(TF
a)))))))))))))))))))))))))))))))))))))))))))))))))
In the ambiguity check for: forall a. a ~ TF (a, Int) => Int
- In the type signature for ‘t’: t :: a ~ TF (a, Int) => Int
+ In the type signature for ‘t’: t :: (a ~ TF (a, Int)) => Int
diff --git a/testsuite/tests/polykinds/T7278.stderr b/testsuite/tests/polykinds/T7278.stderr
index f24f9b2aad..3d615c12f7 100644
--- a/testsuite/tests/polykinds/T7278.stderr
+++ b/testsuite/tests/polykinds/T7278.stderr
@@ -2,4 +2,4 @@
T7278.hs:8:43:
‘t’ is applied to too many type arguments
In the type signature for ‘f’:
- f :: C (t :: k) (TF t) => TF t p1 p0 -> t p1 p0
+ f :: (C (t :: k) (TF t)) => TF t p1 p0 -> t p1 p0
diff --git a/testsuite/tests/typecheck/should_fail/ContextStack2.stderr b/testsuite/tests/typecheck/should_fail/ContextStack2.stderr
index a9c5cbc13a..e99e4c4264 100644
--- a/testsuite/tests/typecheck/should_fail/ContextStack2.stderr
+++ b/testsuite/tests/typecheck/should_fail/ContextStack2.stderr
@@ -6,4 +6,4 @@ ContextStack2.hs:8:6:
TF (TF (TF (TF (TF (TF (TF (TF (TF (TF (TF Int)))))))))))
~ TF (TF (TF (TF (TF (TF (TF (TF (TF (TF a)))))))))
In the ambiguity check for: forall a. a ~ TF (a, Int) => Int
- In the type signature for ‘t’: t :: a ~ TF (a, Int) => Int
+ In the type signature for ‘t’: t :: (a ~ TF (a, Int)) => Int
diff --git a/testsuite/tests/typecheck/should_fail/T7609.stderr b/testsuite/tests/typecheck/should_fail/T7609.stderr
index 1b904bbec7..b02dbe20f8 100644
--- a/testsuite/tests/typecheck/should_fail/T7609.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7609.stderr
@@ -1,10 +1,10 @@
-
-T7609.hs:7:16:
- Expecting one more argument to ‘Maybe’
- The second argument of a tuple should have kind ‘*’,
- but ‘Maybe’ has kind ‘* -> *’
- In the type signature for ‘f’: f :: (a `X` a, Maybe)
-
-T7609.hs:10:7:
- Expected a constraint, but ‘a `X` a’ has kind ‘*’
- In the type signature for ‘g’: g :: a `X` a => Maybe
+
+T7609.hs:7:16:
+ Expecting one more argument to ‘Maybe’
+ The second argument of a tuple should have kind ‘*’,
+ but ‘Maybe’ has kind ‘* -> *’
+ In the type signature for ‘f’: f :: (a `X` a, Maybe)
+
+T7609.hs:10:7:
+ Expected a constraint, but ‘a `X` a’ has kind ‘*’
+ In the type signature for ‘g’: g :: (a `X` a) => Maybe
diff --git a/testsuite/tests/typecheck/should_fail/T7778.stderr b/testsuite/tests/typecheck/should_fail/T7778.stderr
index 714e2a6e27..136625af75 100644
--- a/testsuite/tests/typecheck/should_fail/T7778.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7778.stderr
@@ -2,4 +2,4 @@
T7778.hs:3:19:
Expecting one more argument to ‘Num’
Expected a type, but ‘Num’ has kind ‘* -> Constraint’
- In the type signature for ‘v’: v :: (Num Int => Num) () => ()
+ In the type signature for ‘v’: v :: ((Num Int => Num) ()) => ()
diff --git a/testsuite/tests/typecheck/should_fail/T8392a.stderr b/testsuite/tests/typecheck/should_fail/T8392a.stderr
index ae7fc2ca6a..ed33600a1e 100644
--- a/testsuite/tests/typecheck/should_fail/T8392a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8392a.stderr
@@ -4,4 +4,4 @@ T8392a.hs:6:8:
Inaccessible code in
the type signature for foo :: Int ~ Bool => a -> a
In the ambiguity check for: forall a. Int ~ Bool => a -> a
- In the type signature for ‘foo’: foo :: Int ~ Bool => a -> a
+ In the type signature for ‘foo’: foo :: (Int ~ Bool) => a -> a
diff --git a/testsuite/tests/typecheck/should_fail/T8806.stderr b/testsuite/tests/typecheck/should_fail/T8806.stderr
index 0a5a3d731f..5d50c4ec10 100644
--- a/testsuite/tests/typecheck/should_fail/T8806.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8806.stderr
@@ -5,4 +5,4 @@ T8806.hs:5:6:
T8806.hs:8:7:
Expected a constraint, but ‘Int’ has kind ‘*’
- In the type signature for ‘g’: g :: Int => Show a => Int
+ In the type signature for ‘g’: g :: (Int => Show a) => Int
diff --git a/testsuite/tests/typecheck/should_fail/tcfail032.stderr b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
index 954a6fd5ec..4d41c103da 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail032.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail032.stderr
@@ -8,5 +8,5 @@ tcfail032.hs:14:8:
Relevant bindings include
x :: t (bound at tcfail032.hs:14:3)
f :: t -> a -> Int (bound at tcfail032.hs:14:1)
- In the expression: (x :: Eq a => a -> Int)
- In an equation for ‘f’: f x = (x :: Eq a => a -> Int)
+ In the expression: (x :: (Eq a) => a -> Int)
+ In an equation for ‘f’: f x = (x :: (Eq a) => a -> Int)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail058.stderr b/testsuite/tests/typecheck/should_fail/tcfail058.stderr
index 101a6a07d2..74db76afd8 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail058.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail058.stderr
@@ -2,4 +2,4 @@
tcfail058.hs:6:7:
Expecting one more argument to ‘Array a’
Expected a constraint, but ‘Array a’ has kind ‘* -> *’
- In the type signature for ‘f’: f :: Array a => a -> b
+ In the type signature for ‘f’: f :: (Array a) => a -> b
diff --git a/testsuite/tests/typecheck/should_fail/tcfail215.stderr b/testsuite/tests/typecheck/should_fail/tcfail215.stderr
index d7fa2d84f7..2157561827 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail215.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail215.stderr
@@ -1,4 +1,4 @@
tcfail215.hs:8:15:
Expecting a lifted type, but ‘Int#’ is unlifted
- In the type signature for ‘foo’: foo :: ?x :: Int# => Int
+ In the type signature for ‘foo’: foo :: (?x :: Int#) => Int