[GHC] #16203: Unhelpful names for wildcard type variables

#16203: Unhelpful names for wildcard type variables
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Consider
{{{
{-# LANGUAGE PartialTypeSignatures #-}
f :: _ -> _
f x = x
}}}
With GHC 8.6 we got
{{{
T16152.hs:10:6: warning: [-Wpartial-type-signatures]
• Found type wildcard ‘_’ standing for ‘w’
Where: ‘w’ is a rigid type variable bound by
the inferred type of f :: w -> w
at T16152.hs:11:1-7
• In the type signature: f :: _ -> _
|
10 | f :: _ -> _
| ^
T16152.hs:10:11: warning: [-Wpartial-type-signatures]
• Found type wildcard ‘_’ standing for ‘w’
Where: ‘w’ is a rigid type variable bound by
the inferred type of f :: w -> w
at T16152.hs:11:1-7
• In the type signature: f :: _ -> _
|
10 | f :: _ -> _
| ^
}}}
But with HEAD we get
{{{
T16152.hs:10:6: warning: [-Wpartial-type-signatures]
• Found type wildcard ‘_’ standing for ‘_’
Where: ‘_’ is a rigid type variable bound by
the inferred type of f :: _ -> _
at T16152.hs:11:1-7
• In the type ‘_ -> _’
In the type signature: f :: _ -> _
|
10 | f :: _ -> _
| ^
T16152.hs:10:11: warning: [-Wpartial-type-signatures]
• Found type wildcard ‘_’ standing for ‘_’
Where: ‘_’ is a rigid type variable bound by
the inferred type of f :: _ -> _
at T16152.hs:11:1-7
• In the type ‘_ -> _’
In the type signature: f :: _ -> _
|
10 | f :: _ -> _
| ^
}}}
Saying "Found type wildcard ‘_’ standing for ‘_’" is unhelpful. The "w"
form is much better.
The change is caused by
{{{
commit 17bd163566153babbf51adaff8397f948ae363ca
Author: mynguyen

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * owner: (none) => goldfire -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => PartialTypeSignatures -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This is a consequence of #16082. I do not see an easy solution that isn't ugly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I propose simply reversing the one line change in the Description. I do not know why that change was made. Why is it ugly to reverse it? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Suppose we have {{{#!hs type family F a b where F _ _ = Bool }}} If we reverse the change, I believe we get that GHC reports that the equation is `F w1 w2 = Bool`. Perhaps that's better than what we have, but someone has to pay the price. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Due to #16082, we're going to pretty-print certain things less than optimally regardless of whether we choose `w` or `_`—it's just a question of which pill we find easier to swallow. I don't have a strong opinion on the matter, but it is worth noting that the choice of `_` actually causes some things to be printed out in a manner that's flat-out incorrect. For example, here is the [https://gitlab.haskell.org/ghc/ghc/blob/master/testsuite/tests/partial- sigs/should_compile/Either.stderr stderr from the Either test]: {{{ TYPE SIGNATURES barry :: forall _. _ -> (Either [Char] _, Either [Char] _) Dependent modules: [] Dependent packages: [base-4.12.0.0, ghc-prim-0.5.3, integer-gmp-1.0.2.0] }}} Notice the use of `forall _` there, which isn't valid GHC code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16203: Unhelpful names for wildcard type variables -------------------------------------+------------------------------------- Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | PartialTypeSignatures Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Perhaps in light of comment:6, we should revert that one-line change. But the bug just morphs into a different suboptimal pretty-printing... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16203#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC