[GHC] #7688: :kind should do kind generalisation

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Suppose you load this into GHCi: {{{ {-# LANGUAGE PolyKinds #-} module Test where data Proxy (t::k) = Proxy }}} Now you use `:kind` to see the kind of `Proxy`: {{{ ghci> :k Proxy Proxy :: * -> * }}} It is true that `Proxy` has that kind but it has a more polymorphic kind, and that's the one we'd like to see. The trouble is this. `Proxy` really does have a polymorphic kind. However, `:kind` takes a '''type''' (not a type constructor) as its argument, so you can say {{{ :kind (Maybe Int) }}} for example. So as usual we instantiate `Proxy` with fresh kind variables -- '''BUT''' `:kind` does not do kind generalisation, so we get a monomorphic instance. (And we default unbound kind variables to `*`. Conclusion: `:kind` should do kind-generalisation. See also #7586 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by kosmikus): It seems to me that this is just a question of flags set in GHCi: {{{ GHCi, version 7.6.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Test ( PolyKinds.hs, interpreted ) Ok, modules loaded: Test. *Test> :kind Proxy Proxy :: * -> * *Test> :set -XPolyKinds *Test> :kind Proxy Proxy :: k -> * }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by simonpj): Ha ha ha. You are quite right. GHC ''does'' kind-generalise types, but only if `-XPolyKinds` is on; and it's on in module `Test` but not at the interactive prompt. So I'm confused by my own compiler. Advice about better UI signalling or whatever would be welcome. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by goldfire): I don't know how hard it would be to implement, but you could always ask the user if they intended to turn on {{{-XPolyKinds}}} whenever having that option on would have produced a different output than having that option off. I've hit this problem numerous times and almost even wrote a bug report similar to yours, before I figured out what was going on. This issue is what prompted me finally to write a {{{ghci.conf}}} file. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by spl): Isn't this an instance of a general problem? GHCi does not take into account the flags in files for the prompt. I've seen this in other cases. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * cc: sheard@… (added) Comment: The general problem is that many files are loaded, so which flags would you like to be in force? I do wonder whether, at least for `:kind`, we could temporarily switch on `PolyKinds`, precisely to get the type generalised. That would be easy; would have no effect if the types mentioned were not themselves polykinded; and would probably lead to fewer surprises. It's a bit ad hoc, but I think it'd be an improvement. Any other opinions? Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

I do wonder whether, at least for `:kind`, we could temporarily switch on `PolyKinds`, precisely to get the type generalised. That would be easy; would have no effect if the types mentioned were not themselves
#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by dreixel): Replying to [comment:5 simonpj]: polykinded; and would probably lead to fewer surprises. I think this is a good idea, and I couldn't come up with an example where a user might be possibly surprised at seeing unexpected polykinded stuff (since we default kinds to `*` when `PolyKinds` is off). -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7688: :kind should do kind generalisation
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.6.2
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by simonpj@…):
commit ed2108267b93e6abd769192bdc8fe86cefef7a70
{{{
Author: Simon Peyton Jones

#7688: :kind should do kind generalisation ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.6.2 Resolution: fixed | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: ghci/scripts/T7688 | Blockedby: Blocking: | Related: ---------------------------------+------------------------------------------ Changes (by simonpj): * status: new => closed * testcase: => ghci/scripts/T7688 * resolution: => fixed Comment: OK I did this. It's a very small change, easy to revert Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7688#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC