[GHC] #11714: Kind of (->) type constructor is overly constrained

GHC ghc-devs at haskell.org
Sun Oct 2 23:51:29 UTC 2016


#11714: Kind of (->) type constructor is overly constrained
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:  Typeable
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 bgamari:

@@ -13,3 +13,2 @@
- in a prefix way, thus:  `(->) Int# Int#`.  And this is unusual.
- because they are never in scope in the source
- }}}
+ in a prefix way, thus:  `(->) Int# Int#`.  And this is unusual because
+ they are never in scope in the source

New description:

 Currently the `(->)` type constructor has kind `* -> * -> *` (with some
 magic to make infix work for unlifted types. To quote the comment attached
 to `TysPrim.funTyCon`,

 > You might think that `(->)` should have type `?? -> ? -> *`, and you'd
 be right. But if we do that we get kind errors when saying
 > {{{
 > instance Control.Arrow (->)
 > }}}
 > because the expected kind is `* -> * -> *`.  The trouble is that the
 expected/actual stuff in the unifier does not go contra-variant, whereas
 the kind sub-typing does.  Sigh.  It really only matters if you use `(->)`
 in a prefix way, thus:  `(->) Int# Int#`.  And this is unusual because
 they are never in scope in the source

 This seems to imply that the restrictive kind arose out of the old
 subkinding story. Now that we have a more principled way of dealing with
 non-lifted kinds it seems we allow prefix uses to be as polymorphic as
 infix uses. Something like,
 {{{#!hs
 (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep).
         TYPE rep1 -> TYPE rep2 -> *
 }}}

 Not only would this be a win for consistency, but it may also address some
 of the Core Lint issues that I'm seeing in #11011.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11714#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list