diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-12-01 17:38:23 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-01 18:45:23 +0100 |
commit | 1e041b7382b6aa329e4ad9625439f811e0f27232 (patch) | |
tree | 91f4418553a1e6df072f56f43b5697d40c985b5f /testsuite/tests/ghci | |
parent | b432e2f39c095d8acbb0cfcc63bd08436c7a3e49 (diff) | |
download | haskell-1e041b7382b6aa329e4ad9625439f811e0f27232.tar.gz |
Refactor treatment of wildcards
This patch began as a modest refactoring of HsType and friends, to
clarify and tidy up exactly where quantification takes place in types.
Although initially driven by making the implementation of wildcards more
tidy (and fixing a number of bugs), I gradually got drawn into a pretty
big process, which I've been doing on and off for quite a long time.
There is one compiler performance regression as a result of all
this, in perf/compiler/T3064. I still need to look into that.
* The principal driving change is described in Note [HsType binders]
in HsType. Well worth reading!
* Those data type changes drive almost everything else. In particular
we now statically know where
(a) implicit quantification only (LHsSigType),
e.g. in instance declaratios and SPECIALISE signatures
(b) implicit quantification and wildcards (LHsSigWcType)
can appear, e.g. in function type signatures
* As part of this change, HsForAllTy is (a) simplified (no wildcards)
and (b) split into HsForAllTy and HsQualTy. The two contructors
appear when and only when the correponding user-level construct
appears. Again see Note [HsType binders].
HsExplicitFlag disappears altogether.
* Other simplifications
- ExprWithTySig no longer needs an ExprWithTySigOut variant
- TypeSig no longer needs a PostRn name [name] field
for wildcards
- PatSynSig records a LHsSigType rather than the decomposed
pieces
- The mysterious 'GenericSig' is now 'ClassOpSig'
* Renamed LHsTyVarBndrs to LHsQTyVars
* There are some uninteresting knock-on changes in Haddock,
because of the HsSyn changes
I also did a bunch of loosely-related changes:
* We already had type synonyms CoercionN/CoercionR for nominal and
representational coercions. I've added similar treatment for
TcCoercionN/TcCoercionR
mkWpCastN/mkWpCastN
All just type synonyms but jolly useful.
* I record-ised ForeignImport and ForeignExport
* I improved the (poor) fix to Trac #10896, by making
TcTyClsDecls.checkValidTyCl recover from errors, but adding a
harmless, abstract TyCon to the envt if so.
* I did some significant refactoring in RnEnv.lookupSubBndrOcc,
for reasons that I have (embarrassingly) now totally forgotten.
It had to do with something to do with import and export
Updates haddock submodule.
Diffstat (limited to 'testsuite/tests/ghci')
-rw-r--r-- | testsuite/tests/ghci/scripts/Defer02.stderr | 267 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T10248.stderr | 16 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7873.stdout | 13 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci050.stderr | 1 |
4 files changed, 140 insertions, 157 deletions
diff --git a/testsuite/tests/ghci/scripts/Defer02.stderr b/testsuite/tests/ghci/scripts/Defer02.stderr index 48ddf4b598..83e9f7d157 100644 --- a/testsuite/tests/ghci/scripts/Defer02.stderr +++ b/testsuite/tests/ghci/scripts/Defer02.stderr @@ -1,195 +1,178 @@ ../../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 ',' + • 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 + • 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: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 + • 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’ - (maybe you haven't applied a function to enough arguments?) - In the expression: 1 - In an equation for ‘d’: d = 1 + • No instance for (Num (a -> a)) arising from the literal ‘1’ + (maybe you haven't applied a function to enough arguments?) + • 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’ - 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' - Relevant bindings include - f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) + • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ + • 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' + • Relevant bindings include + f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) ../../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 + • 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) + h :: forall a. a -> (Char, Char) at ../../typecheck/should_run/Defer01.hs:33:6 - In the expression: x - In the expression: (x, 'c') - Relevant bindings include - x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) - h :: a -> (Char, Char) - (bound at ../../typecheck/should_run/Defer01.hs:34:1) + • In the expression: x + In the expression: (x, 'c') + • Relevant bindings include + x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) + h :: a -> (Char, Char) + (bound at ../../typecheck/should_run/Defer01.hs:34:1) ../../typecheck/should_run/Defer01.hs:39:17: warning: - Couldn't match expected type ‘Bool’ with actual type ‘T a’ - In the first argument of ‘not’, namely ‘(K a)’ - In the expression: (not (K a)) - Relevant bindings include - a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) - i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) + • Couldn't match expected type ‘Bool’ with actual type ‘T a’ + • In the first argument of ‘not’, namely ‘(K a)’ + In the expression: (not (K a)) + • Relevant bindings include + a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) + i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) ../../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 + • 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: - Ambiguous type variable ‘a1’ arising from the literal ‘23’ - prevents the constraint ‘(Num a1)’ from being solved. - Probable fix: use a type annotation to specify what ‘a1’ should be. - These potential instances exist: - instance Num Integer -- Defined in ‘GHC.Num’ - instance Num Double -- Defined in ‘GHC.Float’ - instance Num Float -- Defined in ‘GHC.Float’ - ...plus two others - (use -fprint-potential-instances to see them all) - 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: + • Ambiguous type variable ‘a1’ arising from the literal ‘23’ + prevents the constraint ‘(Num a1)’ from being solved. + Probable fix: use a type annotation to specify what ‘a1’ should be. + These potential instances exist: + instance Num Integer -- Defined in ‘GHC.Num’ + instance Num Double -- Defined in ‘GHC.Float’ + instance Num Float -- Defined in ‘GHC.Float’ + ...plus two others + (use -fprint-potential-instances to see them all) + • 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:1: 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 the type signature for ‘k’: - k :: (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 - -../../typecheck/should_run/Defer01.hs:45:6: warning: - Couldn't match expected type ‘Bool’ with actual type ‘Int’ - In the ambiguity check for the type signature for ‘k’: - k :: (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 ../../typecheck/should_run/Defer01.hs:45:6: warning: - Couldn't match type ‘Int’ with ‘Bool’ - Inaccessible code in - the type signature for: + • Couldn't match type ‘Int’ with ‘Bool’ + Inaccessible code in + the type signature for: + k :: (Int ~ Bool) => Int -> Bool + • In the ambiguity check for ‘k’ + To defer the ambiguity check to use sites, enable AllowAmbiguousTypes + In the type signature: 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 ()’ - Probable cause: ‘putChar’ is applied to too few arguments - In the first argument of ‘(>>)’, namely ‘putChar’ - In the expression: putChar >> putChar 'p' + • Couldn't match expected type ‘IO a0’ + with actual type ‘Char -> IO ()’ + • Probable cause: ‘putChar’ is applied to too few arguments + In the first argument of ‘(>>)’, namely ‘putChar’ + In the expression: putChar >> putChar 'p' *** Exception: ../../typecheck/should_run/Defer01.hs:11:40: error: - 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 ',' + • 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: error: - Couldn't match expected type ‘Int’ with actual type ‘Char’ - In the expression: 'p' - In an equation for ‘a’: a = 'p' + • 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: error: - No instance for (Eq B) arising from a use of ‘==’ - In the expression: x == x - In an equation for ‘b’: b x = x == x + • 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>:7:11: error: - Couldn't match type ‘Bool’ with ‘Int’ - Expected type: C Int - Actual type: C Bool - In the first argument of ‘c’, namely ‘(C2 True)’ - In the first argument of ‘print’, namely ‘(c (C2 True))’ + • Couldn't match type ‘Bool’ with ‘Int’ + Expected type: C Int + Actual type: C Bool + • 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: error: - No instance for (Num (a -> a)) arising from the literal ‘1’ - (maybe you haven't applied a function to enough arguments?) - In the expression: 1 - In an equation for ‘d’: d = 1 + • No instance for (Num (a -> a)) arising from the literal ‘1’ + (maybe you haven't applied a function to enough arguments?) + • In the expression: 1 + In an equation for ‘d’: d = 1 (deferred type error) *** Exception: ../../typecheck/should_run/Defer01.hs:31:5: error: - Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - 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' - Relevant bindings include - f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) + • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ + • 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' + • Relevant bindings include + f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) (deferred type error) *** Exception: ../../typecheck/should_run/Defer01.hs:34:8: error: - Couldn't match expected type ‘Char’ with actual type ‘a’ - ‘a’ is a rigid type variable bound by + • 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) + h :: forall a. a -> (Char, Char) at ../../typecheck/should_run/Defer01.hs:33:6 - In the expression: x - In the expression: (x, 'c') - Relevant bindings include - x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) - h :: a -> (Char, Char) - (bound at ../../typecheck/should_run/Defer01.hs:34:1) + • In the expression: x + In the expression: (x, 'c') + • Relevant bindings include + x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) + h :: a -> (Char, Char) + (bound at ../../typecheck/should_run/Defer01.hs:34:1) (deferred type error) *** Exception: ../../typecheck/should_run/Defer01.hs:39:17: error: - Couldn't match expected type ‘Bool’ with actual type ‘T a’ - In the first argument of ‘not’, namely ‘(K a)’ - In the expression: (not (K a)) - Relevant bindings include - a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) - i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) + • Couldn't match expected type ‘Bool’ with actual type ‘T a’ + • In the first argument of ‘not’, namely ‘(K a)’ + In the expression: (not (K a)) + • Relevant bindings include + a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) + i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) (deferred type error) *** Exception: ../../typecheck/should_run/Defer01.hs:43:5: error: - No instance for (MyClass a1) arising from a use of ‘myOp’ - In the expression: myOp 23 - In an equation for ‘j’: j = myOp 23 + • 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>:13:8: error: - 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) + • 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: error: - Couldn't match expected type ‘IO a0’ - with actual type ‘Char -> IO ()’ - Probable cause: ‘putChar’ is applied to too few arguments - In the first argument of ‘(>>)’, namely ‘putChar’ - In the expression: putChar >> putChar 'p' + • Couldn't match expected type ‘IO a0’ + with actual type ‘Char -> IO ()’ + • Probable cause: ‘putChar’ is applied to too few arguments + In the first argument of ‘(>>)’, namely ‘putChar’ + In the expression: putChar >> putChar 'p' (deferred type error) diff --git a/testsuite/tests/ghci/scripts/T10248.stderr b/testsuite/tests/ghci/scripts/T10248.stderr index 86b8c8d688..c9df22b056 100644 --- a/testsuite/tests/ghci/scripts/T10248.stderr +++ b/testsuite/tests/ghci/scripts/T10248.stderr @@ -1,14 +1,14 @@ <interactive>:2:10: error: - Found hole: _ :: f a - Where: ‘f’ is a rigid type variable bound by + • Found hole: _ :: f a + Where: ‘f’ is a rigid type variable bound by the inferred type of it :: Functor f => f (Maybe a) at <interactive>:2:1 - ‘a’ is a rigid type variable bound by + ‘a’ is a rigid type variable bound by the inferred type of it :: Functor f => f (Maybe a) at <interactive>:2:1 - In the second argument of ‘(<$>)’, namely ‘_’ - In the expression: Just <$> _ - In an equation for ‘it’: it = Just <$> _ - Relevant bindings include - it :: f (Maybe a) (bound at <interactive>:2:1) + • In the second argument of ‘(<$>)’, namely ‘_’ + In the expression: Just <$> _ + In an equation for ‘it’: it = Just <$> _ + • Relevant bindings include + it :: f (Maybe a) (bound at <interactive>:2:1) diff --git a/testsuite/tests/ghci/scripts/T7873.stdout b/testsuite/tests/ghci/scripts/T7873.stdout index 79a75ec7ea..84f3117958 100644 --- a/testsuite/tests/ghci/scripts/T7873.stdout +++ b/testsuite/tests/ghci/scripts/T7873.stdout @@ -1,7 +1,6 @@ -data D1 where - MkD1 :: (forall (k1 :: BOX) (p :: k1 -> *) (a :: k1). p a -> Int) - -> D1 - -- Defined at <interactive>:2:1 -data D2 where - MkD2 :: (forall (p :: k -> *) (a :: k). p a -> Int) -> D2 - -- Defined at <interactive>:3:1 +data D1 where
+ MkD1 :: (forall (p :: k -> *) (a :: k). p a -> Int) -> D1
+ -- Defined at <interactive>:2:1
+data D2 where
+ MkD2 :: (forall (p :: k -> *) (a :: k). p a -> Int) -> D2
+ -- Defined at <interactive>:3:1
diff --git a/testsuite/tests/ghci/scripts/ghci050.stderr b/testsuite/tests/ghci/scripts/ghci050.stderr index 31232b6b0b..e8cc7971db 100644 --- a/testsuite/tests/ghci/scripts/ghci050.stderr +++ b/testsuite/tests/ghci/scripts/ghci050.stderr @@ -11,3 +11,4 @@ a :: a (bound at <interactive>:5:41) asList :: (a, a) -> [ListableElem (a, a)] (bound at <interactive>:5:33) + |