Commit ad14efd5 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Some tidying up of type pretty-printing

Triggered by the changes in #13677, I ended up doing a bit of
refactoring in type pretty-printing.

* We were using TyOpPrec and FunPrec rather inconsitently, so
  I made it consisent.

* That exposed the fact that we were a bit undecided about whether
  to print
     a + b -> c + d   vs   (a+b) -> (c+d)
  and similarly
     a ~ [b] => blah  vs   (a ~ [b]) => blah

  I decided to make TyOpPrec and FunPrec compare equal
  (in BasicTypes), so (->) is treated as equal precedence with
  other type operators, so you get the unambiguous forms above,
  even though they have more parens.

  We could readily reverse this decision.
  See Note [Type operator precedence] in BasicTypes

* I fixed a bug in pretty-printing of HsType where some
  parens were omitted by mistake.
parent 226860e7
...@@ -700,13 +700,68 @@ data TyPrec -- See Note [Precedence in types] in TyCoRep.hs ...@@ -700,13 +700,68 @@ data TyPrec -- See Note [Precedence in types] in TyCoRep.hs
| FunPrec -- Function args; no parens for tycon apps | FunPrec -- Function args; no parens for tycon apps
| TyOpPrec -- Infix operator | TyOpPrec -- Infix operator
| TyConPrec -- Tycon args; no parens for atomic | TyConPrec -- Tycon args; no parens for atomic
deriving( Eq, Ord )
instance Eq TyPrec where
(==) a b = case compare a b of
EQ -> True
_ -> False
instance Ord TyPrec where
compare TopPrec TopPrec = EQ
compare TopPrec _ = LT
compare FunPrec TopPrec = GT
compare FunPrec FunPrec = EQ
compare FunPrec TyOpPrec = EQ -- See Note [Type operator precedence]
compare FunPrec TyConPrec = LT
compare TyOpPrec TopPrec = GT
compare TyOpPrec FunPrec = EQ -- See Note [Type operator precedence]
compare TyOpPrec TyOpPrec = EQ
compare TyOpPrec TyConPrec = LT
compare TyConPrec TyConPrec = EQ
compare TyConPrec _ = GT
maybeParen :: TyPrec -> TyPrec -> SDoc -> SDoc maybeParen :: TyPrec -> TyPrec -> SDoc -> SDoc
maybeParen ctxt_prec inner_prec pretty maybeParen ctxt_prec inner_prec pretty
| ctxt_prec < inner_prec = pretty | ctxt_prec < inner_prec = pretty
| otherwise = parens pretty | otherwise = parens pretty
{- Note [Precedence in types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many pretty-printing functions have type
ppr_ty :: TyPrec -> Type -> SDoc
The TyPrec gives the binding strength of the context. For example, in
T ty1 ty2
we will pretty-print 'ty1' and 'ty2' with the call
(ppr_ty TyConPrec ty)
to indicate that the context is that of an argument of a TyConApp.
We use this consistently for Type and HsType.
Note [Type operator precedence]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We don't keep the fixity of type operators in the operator. So the
pretty printer follows the following precedence order:
TyConPrec Type constructor application
TyOpPrec/FunPrec Operator application and function arrow
We have FunPrec and TyOpPrec to represent the precedence of function
arrow and type operators respectively, but currently we implement
FunPred == TyOpPrec, so that we don't distinguish the two. Reason:
it's hard to parse a type like
a ~ b => c * d -> e - f
By treating TyOpPrec = FunPrec we end up with more parens
(a ~ b) => (c * d) -> (e - f)
But the two are different constructors of TyPrec so we could make
(->) bind more or less tightly if we wanted.
-}
{- {-
************************************************************************ ************************************************************************
* * * *
......
...@@ -1286,7 +1286,7 @@ ppr_mono_ty _ (HsListTy ty) = brackets (ppr_mono_lty TopPrec ty) ...@@ -1286,7 +1286,7 @@ 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 _ (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 prec (HsIParamTy n ty) = maybeParen prec FunPrec (ppr n <+> dcolon <+> ppr_mono_lty TopPrec ty)
ppr_mono_ty _ (HsSpliceTy s _) = pprSplice s ppr_mono_ty _ (HsSpliceTy s _) = pprSplice s
ppr_mono_ty _ (HsCoreTy ty) = ppr ty ppr_mono_ty prec (HsCoreTy ty) = pprPrecType prec ty
ppr_mono_ty _ (HsExplicitListTy Promoted _ tys) ppr_mono_ty _ (HsExplicitListTy Promoted _ tys)
= quote $ brackets (interpp'SP tys) = quote $ brackets (interpp'SP tys)
ppr_mono_ty _ (HsExplicitListTy NotPromoted _ tys) ppr_mono_ty _ (HsExplicitListTy NotPromoted _ tys)
...@@ -1300,7 +1300,7 @@ ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) ...@@ -1300,7 +1300,7 @@ ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2)
ppr_mono_lty TyOpPrec ty1 <+> char '~' <+> ppr_mono_lty TyOpPrec ty2 ppr_mono_lty TyOpPrec ty1 <+> char '~' <+> ppr_mono_lty TyOpPrec ty2
ppr_mono_ty _ctxt_prec (HsAppsTy tys) ppr_mono_ty _ctxt_prec (HsAppsTy tys)
= hsep (map (ppr_app_ty TopPrec . unLoc) tys) = hsep (map (ppr_app_ty TyConPrec . unLoc) tys)
ppr_mono_ty _ctxt_prec (HsAppTy fun_ty arg_ty) ppr_mono_ty _ctxt_prec (HsAppTy fun_ty arg_ty)
= hsep [ppr_mono_lty FunPrec fun_ty, ppr_mono_lty TyConPrec arg_ty] = hsep [ppr_mono_lty FunPrec fun_ty, ppr_mono_lty TyConPrec arg_ty]
......
...@@ -30,7 +30,7 @@ module IfaceType ( ...@@ -30,7 +30,7 @@ module IfaceType (
tcArgsIfaceTypes, tcArgsIfaceTypes,
-- Printing -- Printing
pprIfaceType, pprParendIfaceType, pprIfaceType, pprParendIfaceType, pprPrecIfaceType,
pprIfaceContext, pprIfaceContextArr, pprIfaceContext, pprIfaceContextArr,
pprIfaceIdBndr, pprIfaceLamBndr, pprIfaceTvBndr, pprIfaceTyConBinders, pprIfaceIdBndr, pprIfaceLamBndr, pprIfaceTvBndr, pprIfaceTyConBinders,
pprIfaceBndrs, pprIfaceTcArgs, pprParendIfaceTcArgs, pprIfaceBndrs, pprIfaceTcArgs, pprParendIfaceTcArgs,
...@@ -227,6 +227,7 @@ Namely we handle these cases, ...@@ -227,6 +227,7 @@ Namely we handle these cases,
eqPrimTyCon ~# ~~ eqPrimTyCon ~# ~~
eqReprPrimTyCon Coercible Coercible eqReprPrimTyCon Coercible Coercible
See Note [The equality types story] in TysPrim.
-} -}
data IfaceTyConInfo -- Used to guide pretty-printing data IfaceTyConInfo -- Used to guide pretty-printing
...@@ -492,15 +493,15 @@ if_print_coercions yes no ...@@ -492,15 +493,15 @@ if_print_coercions yes no
then yes then yes
else no else no
pprIfaceInfixApp :: (TyPrec -> a -> SDoc) -> TyPrec -> SDoc -> a -> a -> SDoc pprIfaceInfixApp :: TyPrec -> SDoc -> SDoc -> SDoc -> SDoc
pprIfaceInfixApp pp p pp_tc ty1 ty2 pprIfaceInfixApp ctxt_prec pp_tc pp_ty1 pp_ty2
= maybeParen p FunPrec $ = maybeParen ctxt_prec TyOpPrec $
sep [pp FunPrec ty1, pprInfixVar True pp_tc <+> pp FunPrec ty2] sep [pp_ty1, pp_tc <+> pp_ty2]
pprIfacePrefixApp :: TyPrec -> SDoc -> [SDoc] -> SDoc pprIfacePrefixApp :: TyPrec -> SDoc -> [SDoc] -> SDoc
pprIfacePrefixApp p pp_fun pp_tys pprIfacePrefixApp ctxt_prec pp_fun pp_tys
| null pp_tys = pp_fun | null pp_tys = pp_fun
| otherwise = maybeParen p TyConPrec $ | otherwise = maybeParen ctxt_prec TyConPrec $
hang pp_fun 2 (sep pp_tys) hang pp_fun 2 (sep pp_tys)
-- ----------------------------- Printing binders ------------------------------------ -- ----------------------------- Printing binders ------------------------------------
...@@ -565,8 +566,11 @@ instance Outputable IfaceType where ...@@ -565,8 +566,11 @@ instance Outputable IfaceType where
ppr ty = pprIfaceType ty ppr ty = pprIfaceType ty
pprIfaceType, pprParendIfaceType :: IfaceType -> SDoc pprIfaceType, pprParendIfaceType :: IfaceType -> SDoc
pprIfaceType = eliminateRuntimeRep (ppr_ty TopPrec) pprIfaceType = pprPrecIfaceType TopPrec
pprParendIfaceType = eliminateRuntimeRep (ppr_ty TyConPrec) pprParendIfaceType = pprPrecIfaceType TyConPrec
pprPrecIfaceType :: TyPrec -> IfaceType -> SDoc
pprPrecIfaceType prec ty = eliminateRuntimeRep (ppr_ty prec) ty
ppr_ty :: TyPrec -> IfaceType -> SDoc ppr_ty :: TyPrec -> IfaceType -> SDoc
ppr_ty _ (IfaceFreeTyVar tyvar) = ppr tyvar -- This is the main reson for IfaceFreeTyVar! ppr_ty _ (IfaceFreeTyVar tyvar) = ppr tyvar -- This is the main reson for IfaceFreeTyVar!
...@@ -880,8 +884,8 @@ pprTyTcApp' ctxt_prec tc tys dflags style ...@@ -880,8 +884,8 @@ pprTyTcApp' ctxt_prec tc tys dflags style
-- Suppress detail unles you _really_ want to see -- Suppress detail unles you _really_ want to see
-> text "(TypeError ...)" -> text "(TypeError ...)"
| Just doc <- ppr_equality tc (tcArgsIfaceTypes tys) | Just doc <- ppr_equality ctxt_prec tc (tcArgsIfaceTypes tys)
-> maybeParen ctxt_prec TyConPrec doc -> doc
| otherwise | otherwise
-> ppr_iface_tc_app ppr_ty ctxt_prec tc tys_wo_kinds -> ppr_iface_tc_app ppr_ty ctxt_prec tc tys_wo_kinds
...@@ -891,9 +895,10 @@ pprTyTcApp' ctxt_prec tc tys dflags style ...@@ -891,9 +895,10 @@ pprTyTcApp' ctxt_prec tc tys dflags style
-- | Pretty-print a type-level equality. -- | Pretty-print a type-level equality.
-- --
-- See Note [Equality predicates in IfaceType]. -- See Note [Equality predicates in IfaceType]
ppr_equality :: IfaceTyCon -> [IfaceType] -> Maybe SDoc -- and Note [The equality types story] in TysPrim
ppr_equality tc args ppr_equality :: TyPrec -> IfaceTyCon -> [IfaceType] -> Maybe SDoc
ppr_equality ctxt_prec tc args
| hetero_eq_tc | hetero_eq_tc
, [k1, k2, t1, t2] <- args , [k1, k2, t1, t2] <- args
= Just $ print_equality (k1, k2, t1, t2) = Just $ print_equality (k1, k2, t1, t2)
...@@ -914,11 +919,10 @@ ppr_equality tc args ...@@ -914,11 +919,10 @@ ppr_equality tc args
hetero_eq_tc = tc_name `hasKey` eqPrimTyConKey -- (~#) hetero_eq_tc = tc_name `hasKey` eqPrimTyConKey -- (~#)
|| tc_name `hasKey` eqReprPrimTyConKey -- (~R#) || tc_name `hasKey` eqReprPrimTyConKey -- (~R#)
|| tc_name `hasKey` heqTyConKey -- (~~) || tc_name `hasKey` heqTyConKey -- (~~)
print_equality args = print_equality args =
sdocWithDynFlags sdocWithDynFlags $ \dflags ->
$ \dflags -> getPprStyle getPprStyle $ \style ->
$ \style -> print_equality' args style dflags print_equality' args style dflags
print_equality' (ki1, ki2, ty1, ty2) style dflags print_equality' (ki1, ki2, ty1, ty2) style dflags
| print_eqs | print_eqs
...@@ -930,14 +934,15 @@ ppr_equality tc args ...@@ -930,14 +934,15 @@ ppr_equality tc args
| otherwise | otherwise
= if tc_name `hasKey` eqReprPrimTyConKey = if tc_name `hasKey` eqReprPrimTyConKey
then text "Coercible" then pprIfacePrefixApp ctxt_prec (text "Coercible")
<+> sep [ pp TyConPrec ty1, pp TyConPrec ty2 ] [pp TyConPrec ty1, pp TyConPrec ty2]
else sep [pp TyOpPrec ty1, char '~', pp TyOpPrec ty2] else pprIfaceInfixApp ctxt_prec (char '~')
(pp TyOpPrec ty1) (pp TyOpPrec ty2)
where where
ppr_infix_eq eq_op ppr_infix_eq eq_op
= sep [ parens (pp TyOpPrec ty1 <+> dcolon <+> pp TyOpPrec ki1) = pprIfaceInfixApp ctxt_prec eq_op
, eq_op (parens (pp TopPrec ty1 <+> dcolon <+> pp TyOpPrec ki1))
, parens (pp TyOpPrec ty2 <+> dcolon <+> pp TyOpPrec ki2) ] (parens (pp TopPrec ty2 <+> dcolon <+> pp TyOpPrec ki2))
print_kinds = gopt Opt_PrintExplicitKinds dflags print_kinds = gopt Opt_PrintExplicitKinds dflags
print_eqs = gopt Opt_PrintEqualityRelations dflags || print_eqs = gopt Opt_PrintEqualityRelations dflags ||
...@@ -963,7 +968,8 @@ ppr_iface_tc_app pp ctxt_prec tc tys ...@@ -963,7 +968,8 @@ ppr_iface_tc_app pp ctxt_prec tc tys
| [ty1,ty2] <- tys -- Infix, two arguments; | [ty1,ty2] <- tys -- Infix, two arguments;
-- we know nothing of precedence though -- we know nothing of precedence though
= pprIfaceInfixApp pp ctxt_prec (ppr tc) ty1 ty2 = pprIfaceInfixApp ctxt_prec (ppr tc)
(pp TyOpPrec ty1) (pp TyOpPrec ty2)
| otherwise | otherwise
= pprIfacePrefixApp ctxt_prec (parens (ppr tc)) (map (pp TyConPrec) tys) = pprIfacePrefixApp ctxt_prec (parens (ppr tc)) (map (pp TyConPrec) tys)
...@@ -1024,7 +1030,8 @@ ppr_co ctxt_prec (IfaceAppCo co1 co2) ...@@ -1024,7 +1030,8 @@ ppr_co ctxt_prec (IfaceAppCo co1 co2)
= maybeParen ctxt_prec TyConPrec $ = maybeParen ctxt_prec TyConPrec $
ppr_co FunPrec co1 <+> pprParendIfaceCoercion co2 ppr_co FunPrec co1 <+> pprParendIfaceCoercion co2
ppr_co ctxt_prec co@(IfaceForAllCo {}) ppr_co ctxt_prec co@(IfaceForAllCo {})
= maybeParen ctxt_prec FunPrec (pprIfaceForAllCoPart tvs (pprIfaceCoercion inner_co)) = maybeParen ctxt_prec FunPrec $
pprIfaceForAllCoPart tvs (pprIfaceCoercion inner_co)
where where
(tvs, inner_co) = split_co co (tvs, inner_co) = split_co co
...@@ -1208,20 +1215,24 @@ instance Binary IfaceTcArgs where ...@@ -1208,20 +1215,24 @@ instance Binary IfaceTcArgs where
-- | Prints "(C a, D b) =>", including the arrow. This is used when we want to -- | Prints "(C a, D b) =>", including the arrow.
-- print a context in a type. -- Used when we want to print a context in a type, so we
-- use FunPrec to decide whether to parenthesise a singleton
-- predicate; e.g. Num a => a -> a
pprIfaceContextArr :: [IfacePredType] -> SDoc pprIfaceContextArr :: [IfacePredType] -> SDoc
pprIfaceContextArr [] = empty pprIfaceContextArr [] = empty
pprIfaceContextArr [pred] = ppr_ty TyOpPrec pred <+> darrow pprIfaceContextArr [pred] = ppr_ty FunPrec pred <+> darrow
pprIfaceContextArr preds = pprIfaceContextArr preds = ppr_parend_preds preds <+> darrow
parens (fsep (punctuate comma (map ppr preds))) <+> darrow
-- | Prints a context or @()@ if empty
-- | Prints a context or @()@ if empty. This is used when, e.g., we want to -- You give it the context precedence
-- display a context in an error message. pprIfaceContext :: TyPrec -> [IfacePredType] -> SDoc
pprIfaceContext :: [IfacePredType] -> SDoc pprIfaceContext _ [] = text "()"
pprIfaceContext [] = parens empty pprIfaceContext prec [pred] = ppr_ty prec pred
pprIfaceContext [pred] = ppr_ty TyOpPrec pred pprIfaceContext _ preds = ppr_parend_preds preds
pprIfaceContext preds = parens (fsep (punctuate comma (map ppr preds)))
ppr_parend_preds :: [IfacePredType] -> SDoc
ppr_parend_preds preds = parens (fsep (punctuate comma (map ppr preds)))
instance Binary IfaceType where instance Binary IfaceType where
put_ _ (IfaceFreeTyVar tv) put_ _ (IfaceFreeTyVar tv)
......
...@@ -1236,7 +1236,7 @@ mkIPErr ctxt cts ...@@ -1236,7 +1236,7 @@ mkIPErr ctxt cts
msg | null givens msg | null givens
= addArising orig $ = addArising orig $
sep [ text "Unbound implicit parameter" <> plural cts sep [ text "Unbound implicit parameter" <> plural cts
, nest 2 (pprTheta preds) ] , nest 2 (pprParendTheta preds) ]
| otherwise | otherwise
= couldNotDeduce givens (preds, orig) = couldNotDeduce givens (preds, orig)
......
...@@ -183,7 +183,7 @@ module TcType ( ...@@ -183,7 +183,7 @@ module TcType (
pprKind, pprParendKind, pprSigmaType, pprKind, pprParendKind, pprSigmaType,
pprType, pprParendType, pprTypeApp, pprTyThingCategory, tyThingCategory, pprType, pprParendType, pprTypeApp, pprTyThingCategory, tyThingCategory,
pprTheta, pprThetaArrowTy, pprClassPred, pprTheta, pprParendTheta, pprThetaArrowTy, pprClassPred,
pprTvBndr, pprTvBndrs, pprTvBndr, pprTvBndrs,
TypeSize, sizeType, sizeTypes, toposortTyVars TypeSize, sizeType, sizeTypes, toposortTyVars
......
...@@ -55,9 +55,10 @@ module TyCoRep ( ...@@ -55,9 +55,10 @@ module TyCoRep (
pickLR, pickLR,
-- * Pretty-printing -- * Pretty-printing
pprType, pprParendType, pprTypeApp, pprTvBndr, pprTvBndrs, pprType, pprParendType, pprPrecType,
pprTypeApp, pprTvBndr, pprTvBndrs,
pprSigmaType, pprSigmaType,
pprTheta, pprForAll, pprUserForAll, pprTheta, pprParendTheta, pprForAll, pprUserForAll,
pprTyVar, pprTyVars, pprTyVar, pprTyVars,
pprThetaArrowTy, pprClassPred, pprThetaArrowTy, pprClassPred,
pprKind, pprParendKind, pprTyLit, pprKind, pprParendKind, pprTyLit,
...@@ -2424,27 +2425,17 @@ defined to use this. @pprParendType@ is the same, except it puts ...@@ -2424,27 +2425,17 @@ defined to use this. @pprParendType@ is the same, except it puts
parens around the type, except for the atomic cases. @pprParendType@ parens around the type, except for the atomic cases. @pprParendType@
works just by setting the initial context precedence very high. works just by setting the initial context precedence very high.
Note [Precedence in types] See Note [Precedence in types] in BasicTypes.
~~~~~~~~~~~~~~~~~~~~~~~~~~
We don't keep the fixity of type operators in the operator. So the pretty printer
follows the following precedence order:
Type constructor application binds more tightly than
Operator 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; it is used consistently for Type and HsType.
-} -}
------------------ ------------------
pprType, pprParendType :: Type -> SDoc pprType, pprParendType :: Type -> SDoc
pprType = pprIfaceType . tidyToIfaceType pprType = pprPrecType TopPrec
pprParendType = pprParendIfaceType . tidyToIfaceType pprParendType = pprPrecType TyConPrec
pprPrecType :: TyPrec -> Type -> SDoc
pprPrecType prec ty = pprPrecIfaceType prec (tidyToIfaceType ty)
pprTyLit :: TyLit -> SDoc pprTyLit :: TyLit -> SDoc
pprTyLit = pprIfaceTyLit . toIfaceTyLit pprTyLit = pprIfaceTyLit . toIfaceTyLit
...@@ -2471,7 +2462,10 @@ pprClassPred clas tys = pprTypeApp (classTyCon clas) tys ...@@ -2471,7 +2462,10 @@ pprClassPred clas tys = pprTypeApp (classTyCon clas) tys
------------ ------------
pprTheta :: ThetaType -> SDoc pprTheta :: ThetaType -> SDoc
pprTheta = pprIfaceContext . map tidyToIfaceType pprTheta = pprIfaceContext TopPrec . map tidyToIfaceType
pprParendTheta :: ThetaType -> SDoc
pprParendTheta = pprIfaceContext TyConPrec . map tidyToIfaceType
pprThetaArrowTy :: ThetaType -> SDoc pprThetaArrowTy :: ThetaType -> SDoc
pprThetaArrowTy = pprIfaceContextArr . map tidyToIfaceType pprThetaArrowTy = pprIfaceContextArr . map tidyToIfaceType
......
...@@ -182,7 +182,8 @@ module Type ( ...@@ -182,7 +182,8 @@ module Type (
cloneTyVarBndr, cloneTyVarBndrs, lookupTyVar, cloneTyVarBndr, cloneTyVarBndrs, lookupTyVar,
-- * Pretty-printing -- * Pretty-printing
pprType, pprParendType, pprTypeApp, pprTyThingCategory, pprShortTyThing, pprType, pprParendType, pprPrecType,
pprTypeApp, pprTyThingCategory, pprShortTyThing,
pprTvBndr, pprTvBndrs, pprForAll, pprUserForAll, pprTvBndr, pprTvBndrs, pprForAll, pprUserForAll,
pprSigmaType, ppSuggestExplicitKinds, pprSigmaType, ppSuggestExplicitKinds,
pprTheta, pprThetaArrowTy, pprClassPred, pprTheta, pprThetaArrowTy, pprClassPred,
......
...@@ -7,15 +7,15 @@ bkpfail24.bkp:14:15: error: ...@@ -7,15 +7,15 @@ bkpfail24.bkp:14:15: error:
• Could not deduce: a ~ b • Could not deduce: a ~ b
from the context: {H1.T} ~ {H2.T} from the context: {H1.T} ~ {H2.T}
bound by the type signature for: bound by the type signature for:
f :: forall a b. {H1.T} ~ {H2.T} => a -> b f :: forall a b. ({H1.T} ~ {H2.T}) => a -> b
at bkpfail24.bkp:13:9-34 at bkpfail24.bkp:13:9-34
‘a’ is a rigid type variable bound by ‘a’ is a rigid type variable bound by
the type signature for: the type signature for:
f :: forall a b. {H1.T} ~ {H2.T} => a -> b f :: forall a b. ({H1.T} ~ {H2.T}) => a -> b
at bkpfail24.bkp:13:9-34 at bkpfail24.bkp:13:9-34
‘b’ is a rigid type variable bound by ‘b’ is a rigid type variable bound by
the type signature for: the type signature for:
f :: forall a b. {H1.T} ~ {H2.T} => a -> b f :: forall a b. ({H1.T} ~ {H2.T}) => a -> b
at bkpfail24.bkp:13:9-34 at bkpfail24.bkp:13:9-34
• In the expression: x • In the expression: x
In an equation for ‘f’: f x = x In an equation for ‘f’: f x = x
......
...@@ -3,7 +3,7 @@ T7558.hs:8:4: error: ...@@ -3,7 +3,7 @@ T7558.hs:8:4: error:
• Occurs check: cannot construct the infinite type: a ~ Maybe a • Occurs check: cannot construct the infinite type: a ~ Maybe a
Inaccessible code in Inaccessible code in
a pattern with constructor: a pattern with constructor:
MkT :: forall a b. a ~ Maybe b => a -> Maybe b -> T a b, MkT :: forall a b. (a ~ Maybe b) => a -> Maybe b -> T a b,
in an equation for ‘f’ in an equation for ‘f’
• In the pattern: MkT x y • In the pattern: MkT x y
In an equation for ‘f’: f (MkT x y) = [x, y] `seq` True In an equation for ‘f’: f (MkT x y) = [x, y] `seq` True
......
...@@ -521,6 +521,6 @@ Derived type family instances: ...@@ -521,6 +521,6 @@ Derived type family instances:
==================== Filling in method body ==================== ==================== Filling in method body ====================
GHC.Base.Functor [T10604_deriving.Proxy *] GHC.Base.Functor [T10604_deriving.Proxy *]
GHC.Base.<$ = GHC.Base.$dm<$ @T10604_deriving.Proxy * GHC.Base.<$ = GHC.Base.$dm<$ @(T10604_deriving.Proxy *)
pattern X' :: () => a ~ [x] => A a -- Defined at <interactive>:4:1 pattern X' :: () => (a ~ [x]) => A a
-- Defined at <interactive>:4:1
...@@ -151,26 +151,26 @@ data Ex a ...@@ -151,26 +151,26 @@ data Ex a
Ex4 (forall a. a -> a) Ex4 (forall a. a -> a)
<document comment> <document comment>
k :: k ::
T () () This argument has type 'T' (T () () This argument has type 'T')
-> (T2 Int Int) This argument has type 'T2 Int Int' -> ((T2 Int Int) This argument has type 'T2 Int Int')
-> (T3 Bool Bool -> ((T3 Bool Bool
-> T4 Float Float) This argument has type @T3 Bool Bool -> T4 Float Float@ -> T4 Float Float) This argument has type @T3 Bool Bool -> T4 Float Float@)
-> T5 () () This argument has a very long description that should -> (T5 () () This argument has a very long description that should
hopefully cause some wrapping to happen when it is finally hopefully cause some wrapping to happen when it is finally
rendered by Haddock in the generated HTML page. rendered by Haddock in the generated HTML page.)
-> IO () This is the result type -> IO () This is the result type
l :: (Int, Int, Float) takes a triple -> Int returns an 'Int' l :: ((Int, Int, Float) takes a triple) -> Int returns an 'Int'
<document comment> <document comment>
m :: m ::
R -> N1 () one of the arguments -> IO Int and the return value R -> (N1 () one of the arguments) -> IO Int and the return value
<document comment> <document comment>
newn :: newn ::
R one of the arguments, an 'R' (R one of the arguments, an 'R')
-> N1 () one of the arguments -> IO Int -> (N1 () one of the arguments) -> IO Int
newn = undefined newn = undefined
<document comment> <document comment>
foreign import ccall unsafe "header.h" o foreign import ccall unsafe "header.h" o
:: Float The input float -> IO Float The output float :: (Float The input float) -> IO Float The output float
<document comment> <document comment>
newp :: Int newp :: Int
newp = undefined newp = undefined
......
==================== Parser ==================== ==================== Parser ====================
module ShouldCompile where 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 test xs ys = xs
==================== Parser ==================== ==================== Parser ====================
module ShouldCompile where module ShouldCompile where
test2 :: a doc1 -> b doc2 -> a doc 3 test2 :: (a doc1 ) -> (b doc2 ) -> a doc 3
test2 x y = x test2 x y = x