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

GHC ghc-devs at haskell.org
Wed Mar 16 23:00:53 UTC 2016


#11714: Kind of (->) type constructor is overly constrained
-------------------------------------+-------------------------------------
           Reporter:  bgamari        |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.2.1
          Component:  Compiler       |           Version:  8.1
           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:
-------------------------------------+-------------------------------------
 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>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list