Commit 441a87a1 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Wibbles to error messages and tests, following ambiguity-check changes

parent 8f01d1e4
......@@ -5,5 +5,5 @@ module T3101 where
type family F a :: *
data Boom = Boom (forall a. F a)
data Boom = Boom (forall a. a -> F a)
deriving Show
......@@ -2,8 +2,13 @@
module Bug where
class A a oops
data D d = D d
instance A a oops => Read (D a)
-- Actually this instance is ambiguous
-- and is now rightly rejected
data E e = E (D e) deriving Read
instance A Int Bool
T5287.hs:6:29:
No instance for (A e oops)
arising from the 'deriving' clause of a data type declaration
The type variable `oops' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there is a potential instance available:
instance A Int Bool -- Defined at T5287.hs:7:10
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Read (E e))
T5287.hs:6:10:
Could not deduce (A a oops0)
arising from the ambiguity check for an instance declaration
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
In the ambiguity check for: forall a oops. A a oops => Read (D a)
In the instance declaration for `Read (D a)'
......@@ -31,6 +31,7 @@ check title expected got
expectedGhcOnlyExtensions :: [String]
expectedGhcOnlyExtensions = [
"AlloAmbiguousTypes",
"RelaxedLayout",
"AlternativeLayoutRule",
"AlternativeLayoutRuleTransitional",
......
../../typecheck/should_run/Defer01.hs:11:40: Warning:
Couldn't match type `Char' with `[Char]'
Expected type: String
Actual type: Char
In the first argument of `putStr', namely ','
In the second argument of `(>>)', namely putStr ','
In the expression: putStr "Hello World" >> putStr ','
../../typecheck/should_run/Defer01.hs:14:5: Warning:
Couldn't match expected type `Int' with actual type `Char'
In the expression: 'p'
In an equation for `a': a = 'p'
../../typecheck/should_run/Defer01.hs:18:9: Warning:
No instance for (Eq B) arising from a use of `=='
In the expression: x == x
In an equation for `b': b x = x == x
../../typecheck/should_run/Defer01.hs:25:4: Warning:
Couldn't match type `Int' with `Bool'
Inaccessible code in
a pattern with constructor
C2 :: Bool -> C Bool,
in an equation for `c'
In the pattern: C2 x
In an equation for `c': c (C2 x) = True
../../typecheck/should_run/Defer01.hs:28:5: Warning:
No instance for (Num (a -> a)) arising from the literal `1'
In the expression: 1
In an equation for `d': d = 1
../../typecheck/should_run/Defer01.hs:31:5: Warning:
Couldn't match expected type `Char -> t' with actual type `Char'
Relevant bindings include
f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1)
The function `e' is applied to one argument,
but its type `Char' has none
In the expression: e 'q'
In an equation for `f': f = e 'q'
../../typecheck/should_run/Defer01.hs:34:8: Warning:
Couldn't match expected type `Char' with actual type `a'
`a' is a rigid type variable bound by
the type signature for h :: a -> (Char, Char)
at ../../typecheck/should_run/Defer01.hs:33:6
Relevant bindings include
h :: a -> (Char, Char)
(bound at ../../typecheck/should_run/Defer01.hs:34:1)
x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3)
In the expression: x
In the expression: (x, 'c')
In an equation for `h': h x = (x, 'c')
../../typecheck/should_run/Defer01.hs:39:17: Warning:
Couldn't match expected type `Bool' with actual type `T a'
Relevant bindings include
i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1)
a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3)
In the return type of a call of `K'
In the first argument of `not', namely `(K a)'
In the expression: (not (K a))
../../typecheck/should_run/Defer01.hs:43:5: Warning:
No instance for (MyClass a1) arising from a use of `myOp'
In the expression: myOp 23
In an equation for `j': j = myOp 23
../../typecheck/should_run/Defer01.hs:43:10: Warning:
No instance for (Num a1) arising from the literal `23'
The type variable `a1' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the first argument of `myOp', namely `23'
In the expression: myOp 23
In an equation for `j': j = myOp 23
../../typecheck/should_run/Defer01.hs:45:6: Warning:
Couldn't match type `Int' with `Bool'
Inaccessible code in
the type signature for k :: Int ~ Bool => Int -> Bool
../../typecheck/should_run/Defer01.hs:46:7: Warning:
Couldn't match expected type `Bool' with actual type `Int'
In the expression: x
In an equation for `k': k x = x
../../typecheck/should_run/Defer01.hs:49:5: Warning:
Couldn't match expected type `IO a0'
with actual type `Char -> IO ()'
In the first argument of `(>>)', namely `putChar'
In the expression: putChar >> putChar 'p'
In an equation for `l': l = putChar >> putChar 'p'
*** Exception: ../../typecheck/should_run/Defer01.hs:11:40:
Couldn't match type `Char' with `[Char]'
Expected type: String
Actual type: Char
In the first argument of `putStr', namely ','
In the second argument of `(>>)', namely putStr ','
In the expression: putStr "Hello World" >> putStr ','
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:14:5:
Couldn't match expected type `Int' with actual type `Char'
In the expression: 'p'
In an equation for `a': a = 'p'
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:18:9:
No instance for (Eq B) arising from a use of `=='
In the expression: x == x
In an equation for `b': b x = x == x
(deferred type error)
<interactive>:8:11:
Couldn't match type `Bool' with `Int'
Expected type: C Int
Actual type: C Bool
In the return type of a call of `C2'
In the first argument of `c', namely `(C2 True)'
In the first argument of `print', namely `(c (C2 True))'
*** Exception: ../../typecheck/should_run/Defer01.hs:28:5:
No instance for (Num (a -> a)) arising from the literal `1'
In the expression: 1
In an equation for `d': d = 1
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:31:5:
Couldn't match expected type `Char -> t' with actual type `Char'
Relevant bindings include
f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1)
The function `e' is applied to one argument,
but its type `Char' has none
In the expression: e 'q'
In an equation for `f': f = e 'q'
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:34:8:
Couldn't match expected type `Char' with actual type `a'
`a' is a rigid type variable bound by
the type signature for h :: a -> (Char, Char)
at ../../typecheck/should_run/Defer01.hs:33:6
Relevant bindings include
h :: a -> (Char, Char)
(bound at ../../typecheck/should_run/Defer01.hs:34:1)
x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3)
In the expression: x
In the expression: (x, 'c')
In an equation for `h': h x = (x, 'c')
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:39:17:
Couldn't match expected type `Bool' with actual type `T a'
Relevant bindings include
i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1)
a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3)
In the return type of a call of `K'
In the first argument of `not', namely `(K a)'
In the expression: (not (K a))
(deferred type error)
*** Exception: ../../typecheck/should_run/Defer01.hs:43:5:
No instance for (MyClass a1) arising from a use of `myOp'
In the expression: myOp 23
In an equation for `j': j = myOp 23
(deferred type error)
<interactive>:14:8:
Couldn't match expected type `Bool' with actual type `Int'
In the first argument of `print', namely `(k 2)'
In the expression: print (k 2)
In an equation for `it': it = print (k 2)
*** Exception: ../../typecheck/should_run/Defer01.hs:49:5:
Couldn't match expected type `IO a0'
with actual type `Char -> IO ()'
In the first argument of `(>>)', namely `putChar'
In the expression: putChar >> putChar 'p'
In an equation for `l': l = putChar >> putChar 'p'
(deferred type error)
..\..\typecheck\should_run\Defer01.hs:11:40: Warning:
Couldn't match type `Char' with `[Char]'
Expected type: String
Actual type: Char
In the first argument of `putStr', namely ','
In the second argument of `(>>)', namely putStr ','
In the expression: putStr "Hello World" >> putStr ','
..\..\typecheck\should_run\Defer01.hs:14:5: Warning:
Couldn't match expected type `Int' with actual type `Char'
In the expression: 'p'
In an equation for `a': a = 'p'
..\..\typecheck\should_run\Defer01.hs:18:9: Warning:
No instance for (Eq B) arising from a use of `=='
In the expression: x == x
In an equation for `b': b x = x == x
..\..\typecheck\should_run\Defer01.hs:25:4: Warning:
Couldn't match type `Int' with `Bool'
Inaccessible code in
a pattern with constructor
C2 :: Bool -> C Bool,
in an equation for `c'
In the pattern: C2 x
In an equation for `c': c (C2 x) = True
..\..\typecheck\should_run\Defer01.hs:28:5: Warning:
No instance for (Num (a -> a)) arising from the literal `1'
In the expression: 1
In an equation for `d': d = 1
..\..\typecheck\should_run\Defer01.hs:31:5: Warning:
Couldn't match expected type `Char -> t' with actual type `Char'
Relevant bindings include
f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
The function `e' is applied to one argument,
but its type `Char' has none
In the expression: e 'q'
In an equation for `f': f = e 'q'
..\..\typecheck\should_run\Defer01.hs:34:8: Warning:
Couldn't match expected type `Char' with actual type `a'
`a' is a rigid type variable bound by
the type signature for h :: a -> (Char, Char)
at ..\..\typecheck\should_run\Defer01.hs:33:6
Relevant bindings include
h :: a -> (Char, Char)
(bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
In the expression: x
In the expression: (x, 'c')
In an equation for `h': h x = (x, 'c')
..\..\typecheck\should_run\Defer01.hs:39:17: Warning:
Couldn't match expected type `Bool' with actual type `T a'
Relevant bindings include
i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
In the return type of a call of `K'
In the first argument of `not', namely `(K a)'
In the expression: (not (K a))
..\..\typecheck\should_run\Defer01.hs:43:5: Warning:
No instance for (MyClass a1) arising from a use of `myOp'
In the expression: myOp 23
In an equation for `j': j = myOp 23
..\..\typecheck\should_run\Defer01.hs:43:10: Warning:
No instance for (Num a1) arising from the literal `23'
The type variable `a1' is ambiguous
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the first argument of `myOp', namely `23'
In the expression: myOp 23
In an equation for `j': j = myOp 23
..\..\typecheck\should_run\Defer01.hs:45:6: Warning:
Couldn't match type `Int' with `Bool'
Inaccessible code in
the type signature for k :: Int ~ Bool => Int -> Bool
In the ambiguity check for: 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'
Inaccessible code in
the type signature for k :: Int ~ Bool => Int -> Bool
..\..\typecheck\should_run\Defer01.hs:46:7: Warning:
Couldn't match expected type `Bool' with actual type `Int'
In the expression: x
In an equation for `k': k x = x
..\..\typecheck\should_run\Defer01.hs:49:5: Warning:
Couldn't match expected type `IO a0'
with actual type `Char -> IO ()'
In the first argument of `(>>)', namely `putChar'
In the expression: putChar >> putChar 'p'
In an equation for `l': l = putChar >> putChar 'p'
*** Exception: ..\..\typecheck\should_run\Defer01.hs:11:40:
Couldn't match type `Char' with `[Char]'
Expected type: String
Actual type: Char
In the first argument of `putStr', namely ','
In the second argument of `(>>)', namely putStr ','
In the expression: putStr "Hello World" >> putStr ','
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:14:5:
Couldn't match expected type `Int' with actual type `Char'
In the expression: 'p'
In an equation for `a': a = 'p'
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:18:9:
No instance for (Eq B) arising from a use of `=='
In the expression: x == x
In an equation for `b': b x = x == x
(deferred type error)
<interactive>:8:11:
Couldn't match type `Bool' with `Int'
Expected type: C Int
Actual type: C Bool
In the return type of a call of `C2'
In the first argument of `c', namely `(C2 True)'
In the first argument of `print', namely `(c (C2 True))'
*** Exception: ..\..\typecheck\should_run\Defer01.hs:28:5:
No instance for (Num (a -> a)) arising from the literal `1'
In the expression: 1
In an equation for `d': d = 1
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:31:5:
Couldn't match expected type `Char -> t' with actual type `Char'
Relevant bindings include
f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
The function `e' is applied to one argument,
but its type `Char' has none
In the expression: e 'q'
In an equation for `f': f = e 'q'
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:34:8:
Couldn't match expected type `Char' with actual type `a'
`a' is a rigid type variable bound by
the type signature for h :: a -> (Char, Char)
at ..\..\typecheck\should_run\Defer01.hs:33:6
Relevant bindings include
h :: a -> (Char, Char)
(bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
In the expression: x
In the expression: (x, 'c')
In an equation for `h': h x = (x, 'c')
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:39:17:
Couldn't match expected type `Bool' with actual type `T a'
Relevant bindings include
i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
In the return type of a call of `K'
In the first argument of `not', namely `(K a)'
In the expression: (not (K a))
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:43:5:
No instance for (MyClass a1) arising from a use of `myOp'
In the expression: myOp 23
In an equation for `j': j = myOp 23
(deferred type error)
<interactive>:14:8:
Couldn't match expected type `Bool' with actual type `Int'
In the first argument of `print', namely `(k 2)'
In the expression: print (k 2)
In an equation for `it': it = print (k 2)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:49:5:
Couldn't match expected type `IO a0'
with actual type `Char -> IO ()'
In the first argument of `(>>)', namely `putChar'
In the expression: putChar >> putChar 'p'
In an equation for `l': l = putChar >> putChar 'p'
(deferred type error)
......@@ -22,17 +22,17 @@ data Type a where
data Expr :: * -> * -> * {- tu a -} where
Const :: Type a -> a -> Expr tu (TU tu a)
Var2 :: String -> TU tu (Type a) -> Expr tu (TU tu a)
Var2 :: a -> TU tu (Type a) -> Expr tu (TU tu a)
bug1 :: Expr Typed Bool -> ()
bug1 (Const TypeBool False) = ()
bug2a :: Expr Typed Bool -> ()
bug2a (Var2 "x" (TypeBool :: Type Bool)) = ()
bug2a (Var2 x (TypeBool :: Type Bool)) = ()
bug2c :: Expr Typed Bool -> ()
bug2c (Var2 "x" TypeBool) = ()
bug2c (Var2 x TypeBool) = ()
bug2b :: Expr Typed (TU Typed Bool) -> ()
bug2b (Var2 "x" TypeBool) = ()
bug2b (Var2 x TypeBool) = ()
......@@ -9,6 +9,6 @@ data T a where
type family F a
bar :: T (F a) -> ()
bar T = ()
bar :: a -> T (F a) -> ()
bar x T = ()
......@@ -6,5 +6,5 @@ module ShouldCompile where
type family Element c :: *
f :: Element x
f = undefined
f :: x -> Element x
f x = undefined
......@@ -4,5 +4,5 @@ module ShouldCompile where
type family T a
f :: T a -> Int
f x = x `seq` 3
f :: a -> T a -> Int
f p x = x `seq` 3
......@@ -7,7 +7,6 @@ T3208b.hs:15:10:
at T3208b.hs:14:9-56
NB: `STerm' is a type function, and may not be injective
The type variable `o0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Expected type: STerm o0
Actual type: OTerm o0
Relevant bindings include
......@@ -23,7 +22,6 @@ T3208b.hs:15:15:
fce' :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
at T3208b.hs:14:9-56
The type variable `o0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Relevant bindings include
fce' :: a -> c (bound at T3208b.hs:15:1)
f :: a (bound at T3208b.hs:15:6)
......
......@@ -30,5 +30,5 @@ joinPatches = id
cleverNamedResolve :: (Conflict (OnPrim p)
,PrimOf (OnPrim p) ~ WithName (PrimOf p))
=> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve = resolveConflicts . joinPatches
=> p -> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve x = resolveConflicts . joinPatches
......@@ -27,5 +27,5 @@ joinPatches = id
cleverNamedResolve :: (Conflict (OnPrim p)
,PrimOf (OnPrim p) ~ WithName (PrimOf p))
=> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve = resolveConflicts . joinPatches
=> p -> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve x = resolveConflicts . joinPatches
......@@ -27,5 +27,18 @@ joinPatches = id
cleverNamedResolve :: (Conflict (OnPrim p)
,PrimOf (OnPrim p) ~ WithName (PrimOf p))
=> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve = resolveConflicts . joinPatches
=> p -> FL (OnPrim p) -> WithName (PrimOf p)
cleverNamedResolve x = resolveConflicts . joinPatches
-- I added the parameter 'x' to make the signature unambiguous
-- I don't think that ambiguity is essential to the original problem
{-
resolveConflicts :: q -> PrimOf q
(w) FL (OnPrim p) ~ q
(w) WithName (PrimOf p) ~ PrimOf q
==>
(w) PrimOf (OnPrim p) ~ PrimOf (FL (OnPrim p))
==>
(w) PrimOf (OnPrim p) ~ PrimOf (OnPrim p)
-}
\ No newline at end of file
NoMatchErr.hs:20:5:
Could not deduce (Memo d0 ~ Memo d)
from the context (Fun d)
bound by the type signature for f :: Fun d => Memo d a -> Memo d a
at NoMatchErr.hs:19:7-37
NB: `Memo' is a type function, and may not be injective
The type variable `d0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Expected type: (d0 -> a) -> Memo d a
Actual type: (d0 -> a) -> Memo d0 a
Relevant bindings include
f :: Memo d a -> Memo d a (bound at NoMatchErr.hs:20:1)
In the first argument of `(.)', namely `abst'
In the expression: abst . appl
In an equation for `f': f = abst . appl
NoMatchErr.hs:19:7:
Could not deduce (Memo d0 ~ Memo d)
from the context (Fun d)
bound by the type signature for f :: Fun d => Memo d a -> Memo d a
at NoMatchErr.hs:19:7-37
NB: `Memo' is a type function, and may not be injective
The type variable `d0' is ambiguous
Expected type: Memo d a -> Memo d a
Actual type: Memo d0 a -> Memo d0 a
In the ambiguity check for:
forall d a. Fun d => Memo d a -> Memo d a
In the type signature for `f': f :: Fun d => Memo d a -> Memo d a
......@@ -7,8 +7,8 @@ type instance where
F a a = Int
F a b = b
g :: F a Bool
g = False
g :: a -> F a Bool
g x = False
......
Overlap10.hs:11:5:
Couldn't match expected type `F a Bool' with actual type `Bool'
Relevant bindings include
g :: F a Bool (bound at Overlap10.hs:11:1)
In the expression: False
In an equation for `g': g = False
Overlap10.hs:11:7:
Couldn't match expected type `F a Bool' with actual type `Bool'
Relevant bindings include
g :: a -> F a Bool (bound at Overlap10.hs:11:1)
x :: a (bound at Overlap10.hs:11:3)
In the expression: False
In an equation for `g': g x = False
......@@ -7,8 +7,8 @@ type instance where
F a a = Int
F a b = b
g :: F a Int
g = (5 :: Int)
g :: a -> F a Int
g x = (5 :: Int)
......
Overlap11.hs:11:6:
Couldn't match expected type `F a Int' with actual type `Int'
Relevant bindings include g :: F a Int (bound at Overlap11.hs:11:1)
In the expression: (5 :: Int)
In an equation for `g': g = (5 :: Int)
Overlap11.hs:11:8:
Couldn't match expected type `F a Int' with actual type `Int'
Relevant bindings include
g :: a -> F a Int (bound at Overlap11.hs:11:1)
x :: a (bound at Overlap11.hs:11:3)
In the expression: (5 :: Int)
In an equation for `g': g x = (5 :: Int)
SimpleFail16.hs:10:12:
Couldn't match expected type `p0 a0' with actual type `F ()'
The type variables `p0', `a0' are ambiguous
Possible cause: the monomorphism restriction applied to: `bar'
Probable fix: give these definition(s) an explicit type signature
or use -XNoMonomorphismRestriction
Relevant bindings include
bar :: p0 a0 (bound at SimpleFail16.hs:10:1)
In the first argument of `foo', namely `(undefined :: F ())'
In the expression: foo (undefined :: F ())
In an equation for `bar': bar = foo (undefined :: F ())