[GHC] #8428: Incorrect type formatting in error messages
#8428: Incorrect type formatting in error messages ------------------------------------+------------------------------------- Reporter: klao | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- I've been trying to write a type signature to something completely analogous to `runST . runIdentityT`, and failing miserably for a long time. At some point I had the following: {{{#!haskell {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ImpredicativeTypes #-} module Test where import Control.Monad.ST import Control.Monad.Trans.Identity runIdST :: IdentityT (forall s. ST s) a -> a runIdST = runST . runIdentityT }}} You can see that I was very confused about `forall` here (probably still am), but what makes it much worse is the error message with which this fails: {{{ src/Test.hs:10:19: Couldn't match type `forall s. ST s a' with `forall s. ST s a' Expected type: IdentityT (forall s. ST s) a -> forall s. ST s a Actual type: IdentityT (forall s. ST s) a -> forall s. ST s a In the second argument of `(.)', namely `runIdentityT' In the expression: runST . runIdentityT In an equation for `runIdST': runIdST = runST . runIdentityT }}} It says it couldn't match `forall s. ST s a` with `forall s. ST s a`. What's up with that?! This has lead me to a long diversion. Finally, we found the right type for this function (and discovered that the problem is also in the `(.)`, which doesn't have the same special treatment as `($)`), and afterwards we realized, that types in the above error message ''are'' actually different. One is `(forall s. (ST s)) a`, and the other is `forall s. ((ST s) a)`. But they are presented in exactly the same way! The issue is in the `instance Outputable Type`, which has too simplistic precedence rules, I guess. Thanks to `@errge` for help with debugging this. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------+------------------------------------------- Reporter: klao | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by klao): * status: new => patch * difficulty: Unknown => Easy (less than 1 hour) Comment: The more I look at the code in `TypeRep.lhs`, the more it looks like a simple omission. I attach a trivial patch that fixes the issue (and doesn't seem to break anything else; at least not according to the test suite). Note that I also removed a spurious `\end{code}` label, which broke emacs' literate Haskell syntax highlighting on this file. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------+------------------------------------------- Reporter: klao | Owner: monoidal Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by monoidal): * owner: => monoidal -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------+------------------------------------------- Reporter: klao | Owner: monoidal Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"a83652ed4aee321063c17df1ad8560712b33103a/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="a83652ed4aee321063c17df1ad8560712b33103a" Show parentheses when printing type (forall x. T1) T2 (#8428) Patch by klao }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------+------------------------------------------- Reporter: klao | Owner: monoidal Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"1420081d39aacaa6c8acfc0f31811a4d6c2d1c5c/testsuite"]: {{{ #!CommitTicketReference repository="testsuite" revision="1420081d39aacaa6c8acfc0f31811a4d6c2d1c5c" Test #8428 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------------+------------------------------------- Reporter: klao | Owner: monoidal Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Easy (less than 1 Test Case: | hour) typecheck/should_fail/T8428 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * testcase: => typecheck/should_fail/T8428 * resolution: => fixed Comment: Looks good, I've pushed it. Thanks for the patch. The type `(forall s. ST s)` should be rejected as a kind error, because under the forall there should be a type of kind *, not * -> * or similar. However, we currently do not detect this (#8388). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8428: Incorrect type formatting in error messages -------------------------------------+------------------------------------- Reporter: klao | Owner: monoidal Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Easy (less than 1 Test Case: | hour) typecheck/should_fail/T8428 | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by simonpj): Thank you. Absolutely right. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8428#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC