[GHC] #10122: PolyKinds: inferred type not as polymorphic as possible

GHC ghc-devs at haskell.org
Fri Feb 27 16:29:51 UTC 2015


#10122: PolyKinds: inferred type not as polymorphic as possible
-------------------------------------+-------------------------------------
        Reporter:  thomie            |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1-rc2
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by adamgundry):

 * cc: adamgundry (added)


Comment:

 I don't think there is actually a bug here, although the lack of explicit
 forall-bound kind variables is certainly unpleasant, and one could argue
 that the current behaviour may not be the most useful one.

 If you turn on `-XPolyKinds` in GHCi (note that it is not enough to load a
 module with `LANGUAGE PolyKinds`) you should find that `:t f1` gives the
 right answer, at least it does in 7.10-rc1. Without `-XPolyKinds`, the
 kind polymorphism is correctly eliminated.

 Moreover, the error in your `PolyFail` example is exactly what the user
 manual documentation would suggest. The fact that "k is generalised at the
 top level of the signature for f1" means that `f1` must work for all `k`,
 but your implementation assumes `k` is `*`. In the usual way of higher-
 rank types, making the signature for f1 as polymorphic as possible amounts
 to placing the most restrictions on the function's definition.

 Suggestions for how to make this clearer in the documentation are welcome.

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


More information about the ghc-tickets mailing list