Commit da9b2ec3 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Print singleton consraints without parens

The main change is in TypeRep.pprTheta, so we print
       Eq a
for a singleton, but
      (Eq a, Show a)
for multiple constraints.

There are lots of trivial knock-on changes to error messages
parent d4f460fe
......@@ -1396,7 +1396,7 @@ cond_functorOK allowFunctions (_, rep_tc, _)
| not (null bad_stupid_theta)
= NotValid (ptext (sLit "Data type") <+> quotes (ppr rep_tc)
<+> ptext (sLit "must not have a class context") <+> pprTheta bad_stupid_theta)
<+> ptext (sLit "must not have a class context:") <+> pprTheta bad_stupid_theta)
| otherwise
= allValid (map check_con data_cons)
......
......@@ -891,7 +891,7 @@ mkTyVarEqErr dflags ctxt extra ct oriented tv1 ty2
tclvl_extra
= nest 2 $
sep [ quotes (ppr tv1) <+> ptext (sLit "is untouchable")
, nest 2 $ ptext (sLit "inside the constraints") <+> pprEvVarTheta given
, nest 2 $ ptext (sLit "inside the constraints:") <+> pprEvVarTheta given
, nest 2 $ ptext (sLit "bound by") <+> ppr skol_info
, nest 2 $ ptext (sLit "at") <+> ppr (tcl_loc env) ]
tv_extra = extraTyVarInfo ctxt tv1 ty2
......@@ -962,15 +962,15 @@ misMatchOrCND ctxt ct oriented ty1 ty2
couldNotDeduce :: [UserGiven] -> (ThetaType, CtOrigin) -> SDoc
couldNotDeduce givens (wanteds, orig)
= vcat [ addArising orig (ptext (sLit "Could not deduce") <+> pprTheta wanteds)
= vcat [ addArising orig (ptext (sLit "Could not deduce:") <+> pprTheta wanteds)
, vcat (pp_givens givens)]
pp_givens :: [UserGiven] -> [SDoc]
pp_givens givens
= case givens of
[] -> []
(g:gs) -> ppr_given (ptext (sLit "from the context")) g
: map (ppr_given (ptext (sLit "or from"))) gs
(g:gs) -> ppr_given (ptext (sLit "from the context:")) g
: map (ppr_given (ptext (sLit "or from:"))) gs
where
ppr_given herald (gs, skol_info, _, loc)
= hang (herald <+> pprEvVarTheta gs)
......
......@@ -525,7 +525,7 @@ pprClassPred clas tys = pprTypeApp (classTyCon clas) tys
------------
pprTheta :: ThetaType -> SDoc
-- pprTheta [pred] = pprPred pred -- I'm in two minds about this
pprTheta [pred] = ppr_type TopPrec pred -- I'm in two minds about this
pprTheta theta = parens (sep (punctuate comma (map (ppr_type TopPrec) theta)))
pprThetaArrowTy :: ThetaType -> SDoc
......
T5287.hs:6:10:
Could not deduce (A a oops0)
from the context (A a oops)
from the context: A a oops
bound by an instance declaration: A a oops => Read (D a)
at T5287.hs:6:10-31
The type variable ‘oops0’ is ambiguous
......
......@@ -19,7 +19,7 @@ drvfail-functor2.hs:15:14:
drvfail-functor2.hs:20:14:
Can't make a derived instance of ‘Functor StupidConstraint’:
Data type ‘StupidConstraint’ must not have a class context (Eq a)
Data type ‘StupidConstraint’ must not have a class context: Eq a
In the data declaration for ‘StupidConstraint’
drvfail-functor2.hs:26:14:
......
gadt-escape1.hs:19:58:
Couldn't match type ‘t’ with ‘ExpGADT Int’
‘t’ is untouchable
inside the constraints (t1 ~ Int)
bound by a pattern with constructor: ExpInt :: Int -> ExpGADT Int,
in a case alternative
at gadt-escape1.hs:19:43-50
‘t’ is a rigid type variable bound by
the inferred type of weird1 :: t at gadt-escape1.hs:19:1
Possible fix: add a type signature for ‘weird1’
Expected type: t
Actual type: ExpGADT t1
Relevant bindings include
weird1 :: t (bound at gadt-escape1.hs:19:1)
In the expression: a
In a case alternative: Hidden (ExpInt _) a -> a
gadt-escape1.hs:19:58:
Couldn't match type ‘t’ with ‘ExpGADT Int’
‘t’ is untouchable
inside the constraints: t1 ~ Int
bound by a pattern with constructor: ExpInt :: Int -> ExpGADT Int,
in a case alternative
at gadt-escape1.hs:19:43-50
‘t’ is a rigid type variable bound by
the inferred type of weird1 :: t at gadt-escape1.hs:19:1
Possible fix: add a type signature for ‘weird1’
Expected type: t
Actual type: ExpGADT t1
Relevant bindings include
weird1 :: t (bound at gadt-escape1.hs:19:1)
In the expression: a
In a case alternative: Hidden (ExpInt _) a -> a
gadt13.hs:15:13:
Couldn't match expected type ‘t’
with actual type ‘String -> [Char]’
‘t’ is untouchable
inside the constraints (t1 ~ Int)
bound by a pattern with constructor: I :: Int -> Term Int,
in an equation for ‘shw’
at gadt13.hs:15:6-8
‘t’ is a rigid type variable bound by
the inferred type of shw :: Term t1 -> t at gadt13.hs:15:1
Possible fix: add a type signature for ‘shw’
Relevant bindings include
shw :: Term t1 -> t (bound at gadt13.hs:15:1)
In the expression: ("I " ++) . shows t
In an equation for ‘shw’: shw (I t) = ("I " ++) . shows t
gadt13.hs:15:13:
Couldn't match expected type ‘t’
with actual type ‘String -> [Char]’
‘t’ is untouchable
inside the constraints: t1 ~ Int
bound by a pattern with constructor: I :: Int -> Term Int,
in an equation for ‘shw’
at gadt13.hs:15:6-8
‘t’ is a rigid type variable bound by
the inferred type of shw :: Term t1 -> t at gadt13.hs:15:1
Possible fix: add a type signature for ‘shw’
Relevant bindings include
shw :: Term t1 -> t (bound at gadt13.hs:15:1)
In the expression: ("I " ++) . shows t
In an equation for ‘shw’: shw (I t) = ("I " ++) . shows t
gadt21.hs:21:60:
Could not deduce (Ord a1) arising from a use of ‘f’
from the context (a ~ Set a1)
bound by a pattern with constructor:
TypeSet :: forall a. Type a -> Type (Set a),
in an equation for ‘withOrdDynExpr’
at gadt21.hs:21:35-43
Possible fix:
add (Ord a1) to the context of the data constructor ‘TypeSet’
In the first argument of ‘Just’, namely ‘(f e)’
In the expression: Just (f e)
In an equation for ‘withOrdDynExpr’:
withOrdDynExpr (DynExpr e@(Const (TypeSet _) _)) f = Just (f e)
gadt21.hs:21:60:
Could not deduce (Ord a1) arising from a use of ‘f’
from the context: a ~ Set a1
bound by a pattern with constructor:
TypeSet :: forall a. Type a -> Type (Set a),
in an equation for ‘withOrdDynExpr’
at gadt21.hs:21:35-43
Possible fix:
add (Ord a1) to the context of the data constructor ‘TypeSet’
In the first argument of ‘Just’, namely ‘(f e)’
In the expression: Just (f e)
In an equation for ‘withOrdDynExpr’:
withOrdDynExpr (DynExpr e@(Const (TypeSet _) _)) f = Just (f e)
gadt7.hs:16:38:
Couldn't match expected type ‘t’ with actual type ‘t1’
‘t1’ is untouchable
inside the constraints (t2 ~ Int)
bound by a pattern with constructor: K :: T Int,
in a case alternative
at gadt7.hs:16:33
‘t1’ is a rigid type variable bound by
the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
‘t’ is a rigid type variable bound by
the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
Possible fix: add a type signature for ‘i1b’
Relevant bindings include
y1 :: t1 (bound at gadt7.hs:16:16)
y :: t1 (bound at gadt7.hs:16:7)
i1b :: T t2 -> t1 -> t (bound at gadt7.hs:16:1)
In the expression: y1
In a case alternative: K -> y1
gadt7.hs:16:38:
Couldn't match expected type ‘t’ with actual type ‘t1’
‘t1’ is untouchable
inside the constraints: t2 ~ Int
bound by a pattern with constructor: K :: T Int,
in a case alternative
at gadt7.hs:16:33
‘t1’ is a rigid type variable bound by
the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
‘t’ is a rigid type variable bound by
the inferred type of i1b :: T t2 -> t1 -> t at gadt7.hs:16:1
Possible fix: add a type signature for ‘i1b’
Relevant bindings include
y1 :: t1 (bound at gadt7.hs:16:16)
y :: t1 (bound at gadt7.hs:16:7)
i1b :: T t2 -> t1 -> t (bound at gadt7.hs:16:1)
In the expression: y1
In a case alternative: K -> y1
......@@ -2,7 +2,7 @@
Simple14.hs:8:8:
Couldn't match type ‘z0’ with ‘z’
‘z0’ is untouchable
inside the constraints (x ~ y)
inside the constraints: x ~ y
bound by the type signature for: eqE :: (x ~ y) => EQ_ z0 z0
at Simple14.hs:8:8-39
‘z’ is a rigid type variable bound by
......
T3208b.hs:15:10:
Could not deduce (STerm o0 ~ OTerm o0)
from the context (OTerm a ~ STerm a, OBJECT a, SUBST a)
Could not deduce: STerm o0 ~ OTerm o0
from the context: (OTerm a ~ STerm a, OBJECT a, SUBST a)
bound by the type signature for:
fce' :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
at T3208b.hs:14:9-56
......@@ -10,8 +10,8 @@ T3208b.hs:15:10:
In an equation for ‘fce'’: fce' f = fce (apply f)
T3208b.hs:15:15:
Could not deduce (OTerm o0 ~ OTerm a)
from the context (OTerm a ~ STerm a, OBJECT a, SUBST a)
Could not deduce: OTerm o0 ~ OTerm a
from the context: (OTerm a ~ STerm a, OBJECT a, SUBST a)
bound by the type signature for:
fce' :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
at T3208b.hs:14:9-56
......
T2664.hs:31:52:
Could not deduce (a ~ b)
from the context ((a :*: b) ~ Dual c, c ~ Dual (a :*: b))
bound by the type signature for:
newPChan :: ((a :*: b) ~ Dual c, c ~ Dual (a :*: b)) =>
IO (PChan (a :*: b), PChan c)
at T2664.hs:23:5-12
‘a’ is a rigid type variable bound by
the instance declaration at T2664.hs:22:10
‘b’ is a rigid type variable bound by
the instance declaration at T2664.hs:22:10
Expected type: Dual (Dual a)
Actual type: b
Relevant bindings include
v :: MVar (Either (PChan a) (PChan b)) (bound at T2664.hs:24:9)
newPChan :: IO (PChan (a :*: b), PChan c) (bound at T2664.hs:23:5)
In the third argument of ‘pchoose’, namely ‘newPChan’
In the first argument of ‘E’, namely ‘(pchoose Right v newPChan)’
In the expression:
E (pchoose Right v newPChan) (pchoose Left v newPChan)
T2664.hs:31:52:
Could not deduce: a ~ b
from the context: ((a :*: b) ~ Dual c, c ~ Dual (a :*: b))
bound by the type signature for:
newPChan :: ((a :*: b) ~ Dual c, c ~ Dual (a :*: b)) =>
IO (PChan (a :*: b), PChan c)
at T2664.hs:23:5-12
‘a’ is a rigid type variable bound by
the instance declaration at T2664.hs:22:10
‘b’ is a rigid type variable bound by
the instance declaration at T2664.hs:22:10
Expected type: Dual (Dual a)
Actual type: b
Relevant bindings include
v :: MVar (Either (PChan a) (PChan b)) (bound at T2664.hs:24:9)
newPChan :: IO (PChan (a :*: b), PChan c) (bound at T2664.hs:23:5)
In the third argument of ‘pchoose’, namely ‘newPChan’
In the first argument of ‘E’, namely ‘(pchoose Right v newPChan)’
In the expression:
E (pchoose Right v newPChan) (pchoose Left v newPChan)
T3440.hs:11:22:
Could not deduce (a1 ~ a)
from the context (Fam a ~ Fam a1)
bound by a pattern with constructor:
GADT :: forall a. a -> Fam a -> GADT (Fam a),
in an equation for ‘unwrap’
at T3440.hs:11:9-16
‘a1’ is a rigid type variable bound by
a pattern with constructor:
GADT :: forall a. a -> Fam a -> GADT (Fam a),
in an equation for ‘unwrap’
at T3440.hs:11:9
‘a’ is a rigid type variable bound by
the type signature for: unwrap :: GADT (Fam a) -> (a, Fam a)
at T3440.hs:10:11
Relevant bindings include
y :: Fam a1 (bound at T3440.hs:11:16)
x :: a1 (bound at T3440.hs:11:14)
unwrap :: GADT (Fam a) -> (a, Fam a) (bound at T3440.hs:11:1)
In the expression: x
In the expression: (x, y)
T3440.hs:11:22:
Could not deduce: a1 ~ a
from the context: Fam a ~ Fam a1
bound by a pattern with constructor:
GADT :: forall a. a -> Fam a -> GADT (Fam a),
in an equation for ‘unwrap’
at T3440.hs:11:9-16
‘a1’ is a rigid type variable bound by
a pattern with constructor:
GADT :: forall a. a -> Fam a -> GADT (Fam a),
in an equation for ‘unwrap’
at T3440.hs:11:9
‘a’ is a rigid type variable bound by
the type signature for: unwrap :: GADT (Fam a) -> (a, Fam a)
at T3440.hs:10:11
Relevant bindings include
y :: Fam a1 (bound at T3440.hs:11:16)
x :: a1 (bound at T3440.hs:11:14)
unwrap :: GADT (Fam a) -> (a, Fam a) (bound at T3440.hs:11:1)
In the expression: x
In the expression: (x, y)
T4093a.hs:7:9:
Could not deduce (Foo e0 ~ Maybe e)
from the context (Foo e ~ Maybe e)
bound by the type signature for: hang :: (Foo e ~ Maybe e) => Foo e
at T4093a.hs:7:9-34
The type variable ‘e0’ is ambiguous
Expected type: Foo e
Actual type: Foo e0
In the ambiguity check for the type signature for ‘hang’:
hang :: forall e. (Foo e ~ Maybe e) => Foo e
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘hang’:
hang :: (Foo e ~ Maybe e) => Foo e
T4093a.hs:7:9:
Could not deduce: Foo e0 ~ Maybe e
from the context: Foo e ~ Maybe e
bound by the type signature for: hang :: (Foo e ~ Maybe e) => Foo e
at T4093a.hs:7:9-34
The type variable ‘e0’ is ambiguous
Expected type: Foo e
Actual type: Foo e0
In the ambiguity check for the type signature for ‘hang’:
hang :: forall e. (Foo e ~ Maybe e) => Foo e
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘hang’:
hang :: (Foo e ~ Maybe e) => Foo e
T4093b.hs:31:13:
Could not deduce (e ~ C)
from the context (EitherCO e (A C O n) (A O O n) ~ A e O n,
EitherCO x (A C C n) (A C O n) ~ A C x n)
Could not deduce: e ~ C
from the context: (EitherCO e (A C O n) (A O O n) ~ A e O n,
EitherCO x (A C C n) (A C O n) ~ A C x n)
bound by the type signature for:
blockToNodeList :: (EitherCO e (A C O n) (A O O n) ~ A e O n,
EitherCO x (A C C n) (A C O n) ~ A C x n) =>
......
......@@ -2,7 +2,7 @@
T8155.hs:26:14:
Could not deduce (Integral (BoundsOf (a -> a)))
arising from a use of ‘buildV’
from the context (Num a)
from the context: Num a
bound by the instance declaration at T8155.hs:25:10-32
In the expression: buildV
In an equation for ‘build'’: build' = buildV
......
......@@ -2,7 +2,7 @@
mod47.hs:6:10:
Could not deduce (Num a)
arising from the superclasses of an instance declaration
from the context (Eq a, Enum a)
from the context: (Eq a, Enum a)
bound by the instance declaration at mod47.hs:6:10-34
Possible fix:
add (Num a) to the context of the instance declaration
......
......@@ -7,7 +7,6 @@ Dependent modules: []
Dependent packages: [base-4.8.0.0, ghc-prim-0.3.1.0,
integer-gmp-1.0.0.0]
WarningWildcardInstantiations.hs:5:14: Warning:
Found hole ‘_a’ with type: w_a
Where: ‘w_a’ is a rigid type variable bound by
......@@ -16,7 +15,7 @@ WarningWildcardInstantiations.hs:5:14: Warning:
In the type signature for ‘foo’: (Show _a, _) => _a -> _
WarningWildcardInstantiations.hs:5:18: Warning:
Found hole ‘_’ with inferred constraints: (Enum w_a)
Found hole ‘_’ with inferred constraints: Enum w_a
In the type signature for ‘foo’: (Show _a, _) => _a -> _
WarningWildcardInstantiations.hs:5:30: Warning:
......@@ -40,7 +39,7 @@ WarningWildcardInstantiations.hs:8:13: Warning:
at WarningWildcardInstantiations.hs:9:1
In the type signature for ‘bar’: _ -> _ -> _
WarningWildcardInstantiations.hs:8:18: Warning:
WarningWildcardInstantiations.hs:8:18: Warning:
Found hole ‘_’ with type: w_1
Where: ‘w_1’ is a rigid type variable bound by
the inferred type of bar :: w_ -> (w_ -> w_1) -> w_1
......
ExtraConstraintsWildcardNotEnabled.hs:4:10:
Found hole ‘_’ with inferred constraints: (Show a)
Found hole ‘_’ with inferred constraints: Show a
To use the inferred type, enable PartialTypeSignatures
In the type signature for ‘show'’: _ => a -> String
......@@ -8,6 +8,6 @@ InstantiatedNamedWildcardsInConstraints.hs:4:14:
In the type signature for ‘foo’: (Enum _a, _) => _a -> (String, b)
InstantiatedNamedWildcardsInConstraints.hs:4:18:
Found hole ‘_’ with inferred constraints: (Show b)
Found hole ‘_’ with inferred constraints: Show b
To use the inferred type, enable PartialTypeSignatures
In the type signature for ‘foo’: (Enum _a, _) => _a -> (String, b)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment