[GHC] #12989: ($) can have a more general type

GHC ghc-devs at haskell.org
Fri Dec 16 00:44:49 UTC 2016


#12989: ($) can have a more general type
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Type checker)                     |
           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:
-------------------------------------+-------------------------------------
 The documentation (in section 9.12.1 for GHC 8; I don't know what section
 it is in 8.2) suggests a hypothetical type for `($)`:

 {{{#!hs
 bad :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
               (a :: TYPE r1) (b :: TYPE r2).
        (a -> b) -> a -> b
 bad f x = f x
 }}}

 It explains, correctly, that this definition will not work because `x` has
 a representation-polymorphic type. However, this doesn't actually explain
 why `($)` doesn't have that type! Indeed, both GHC 8 and 8.2 accept the
 following:

 {{{#!hs
 good :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
               (a :: TYPE r1) (b :: TYPE r2).
        (a -> b) -> a -> b
 good f = f
 }}}

 This has very slightly different semantics, but anyone relying on the
 difference is already doing something they shouldn't. It may or may not be
 possible to retain the current semantics with some care and magic, if we
 so desire.

 I didn't really know how to characterize this ticket properly. It could be
 considered a documentation bug or a compiler feature request.

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


More information about the ghc-tickets mailing list