[GHC] #12540: RFC: Allow not quantifying every top-level quantifiee

GHC ghc-devs at haskell.org
Sat May 26 17:29:01 UTC 2018


#12540: RFC: Allow not quantifying every top-level quantifiee
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14245            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 It's not surprising at all, if you look at it from a certain perspective.
 After all, in this function:

 {{{#!hs
 f :: (forall a. Proxy b -> a -> a) -> Int -> Int
 f g x = g Proxy x
 }}}

 Despite the fact that there's a `forall` in front of `Proxy b -> a -> a`,
 GHC doesn't complain that `b` is out of scope. That's because the `forall
 `-or-nothing rule only applies to `forall`s at the top level, which
 `forall a. Proxy b -> a -> a` is not.

 That's why `const_ :: (forall a. a -> b -> a)` is accepted, since the
 `forall` is similarly not at the top level. It's also why this variation
 is accepted:

 {{{#!hs
 const__ :: () => forall a. a -> b -> a
 const__ = const
 }}}

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


More information about the ghc-tickets mailing list