[GHC] #15415: GHCi's :kind doesn't work with wildcards

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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: -------------------------------------+------------------------------------- Witness this GHCi session: {{{ rae:20:35:37 ~/ghc/ghc-head/ghc> ~/ghc/ghc-head/inplace/bin/ghc-stage2 --interactive GHCi, version 8.7.20180716: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /Users/rae/.ghc/ghci.conf Prelude> :set -XPartialTypeSignatures Prelude> import Data.Proxy Prelude Data.Proxy> :k Proxy _ Proxy _ :: * Prelude Data.Proxy> :k Proxy (Maybe :: _) <interactive>:1:8: error: • Expecting one more argument to ‘Maybe’ Expected kind ‘_’, but ‘Maybe’ has kind ‘* -> *’ • In the first argument of ‘Proxy’, namely ‘(Maybe :: _)’ In the type ‘Proxy (Maybe :: _)’ }}} It seems we're not doing the correct wildcard thing here: GHCi should report that `_` should be `Type -> Type`. I believe that this is because `TcHsType.tcWildCardBinders` uses `newSkolemTyVar` internally; `tcWildCardBinders` is called from `TcRnDriver.tcRnType`, which is the implementation of GHCi's `:kind`. This is GHC's only call of `tcWildCardBinders`. All other places use `tcWildCardBindersX newWildTyVar`, which makes vastly more sense. I would just fix this myself, but it smells intentional. Does anyone know why we have all this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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: | -------------------------------------+------------------------------------- Description changed by goldfire: Old description:
Witness this GHCi session:
{{{ rae:20:35:37 ~/ghc/ghc-head/ghc> ~/ghc/ghc-head/inplace/bin/ghc-stage2 --interactive GHCi, version 8.7.20180716: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /Users/rae/.ghc/ghci.conf Prelude> :set -XPartialTypeSignatures Prelude> import Data.Proxy Prelude Data.Proxy> :k Proxy _ Proxy _ :: * Prelude Data.Proxy> :k Proxy (Maybe :: _)
<interactive>:1:8: error: • Expecting one more argument to ‘Maybe’ Expected kind ‘_’, but ‘Maybe’ has kind ‘* -> *’ • In the first argument of ‘Proxy’, namely ‘(Maybe :: _)’ In the type ‘Proxy (Maybe :: _)’ }}}
It seems we're not doing the correct wildcard thing here: GHCi should report that `_` should be `Type -> Type`.
I believe that this is because `TcHsType.tcWildCardBinders` uses `newSkolemTyVar` internally; `tcWildCardBinders` is called from `TcRnDriver.tcRnType`, which is the implementation of GHCi's `:kind`. This is GHC's only call of `tcWildCardBinders`. All other places use `tcWildCardBindersX newWildTyVar`, which makes vastly more sense.
I would just fix this myself, but it smells intentional. Does anyone know why we have all this?
New description: Witness this GHCi session: {{{ rae:20:35:37 ~/ghc/ghc-head/ghc> ~/ghc/ghc-head/inplace/bin/ghc-stage2 --interactive GHCi, version 8.7.20180716: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /Users/rae/.ghc/ghci.conf Prelude> :set -XPartialTypeSignatures Prelude> import Data.Proxy Prelude Data.Proxy> :k Proxy _ Proxy _ :: * Prelude Data.Proxy> :k Proxy (Maybe :: _) <interactive>:1:8: error: • Expecting one more argument to ‘Maybe’ Expected kind ‘_’, but ‘Maybe’ has kind ‘* -> *’ • In the first argument of ‘Proxy’, namely ‘(Maybe :: _)’ In the type ‘Proxy (Maybe :: _)’ }}} It seems we're not doing the correct wildcard thing here: GHCi should report that `_` should be `Type -> Type`. I believe that this is because `TcHsType.tcWildCardBinders` uses `newSkolemTyVar` internally; `tcWildCardBinders` is called from `TcRnDriver.tcRnType`, which is the implementation of GHCi's `:kind`. This is GHC's only call of `tcWildCardBinders`. All other places use `tcWildCardBindersX newWildTyVar`, which makes vastly more sense. I would just fix this myself, but it smells intentional. Does anyone know why we have all this? (Credit to @int-index who found this bug.) -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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 int-index): * cc: int-index (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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 int-index): * cc: simonpj (added) Comment: The patch that introduced this distinction is 15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72. Simon, do you remember why you decided to separate `tcWildCardBinders` and `tcWildCardBindersX`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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: | -------------------------------------+------------------------------------- Comment (by simonpj):
I would just fix this myself, but it smells intentional. Does anyone know why we have all this?
I've had a look. Just fix it yourself... I have no idea why `tcRnType` should use a subtly-different interface for `tcWildCardBinders`. I suspect it's accidental. I note also that * All the other calls to `tcWildCardBindersX` pass in `newWildTyVar`. If that's what we want in `tcRnType` (and I bet it is) we can just remove the parameter from `tcWildCardBindersX` and use `newWildTyVar` directly. * There is another subtle difference: only the call from `tcRnType` passes in some skolem-info, and the effect of that is to use `scopeTyVars2` which builds an implication etc. I bet this is accidental (and wrong) too. We probably don't need that skolem-info at all. Over to you! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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: | -------------------------------------+------------------------------------- Comment (by int-index): Thanks for looking into, good to know it's not intentional. Richard, have you started implementing a fix? If not, I think I understand this part of code enough to do it myself. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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: | -------------------------------------+------------------------------------- Comment (by goldfire): No, I haven't started this implementation. I'd be grateful to turn it over to you. It shouldn't be hard -- it's essentially just removing code. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5022 Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * status: new => patch * differential: => Phab:D5022 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15415: GHCi's :kind doesn't work with wildcards
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.5
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5022
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#15415: GHCi's :kind doesn't work with wildcards -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5022 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: Merged to `ghc-8.6` with a97ead78b76bfd914adb7c5b331ee364fc6f1928. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15415#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC