[GHC] #10572: Template Haskell does not implicitly quantify types

GHC ghc-devs at haskell.org
Fri Jun 26 03:16:20 UTC 2015


#10572: Template Haskell does not implicitly quantify types
-------------------------------------+-------------------------------------
              Reporter:  spinda      |             Owner:
                  Type:  bug         |            Status:  new
              Priority:  normal      |         Milestone:
             Component:  Template    |           Version:  7.10.1
  Haskell                            |  Operating System:  Unknown/Multiple
              Keywords:              |   Type of failure:  None/Unknown
          Architecture:              |        Blocked By:
  Unknown/Multiple                   |   Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
 Consider the simple quasiquoter producing a type variable:

 {{{
 tv :: QuasiQuoter
 tv = QuasiQuoter { quoteType = varT . mkName }
 }}}

 If a type variable is introduced elsewhere in a type signature, it is
 implicitly quantified as normal and the TH name resolves properly:

 {{{
 id' :: a -> [tv|a|]
 id' x = x
 }}}

 But if the type variable is not mentioned elsewhere in the type, an error
 results:

 {{{
 const' :: a -> [tv|b|] -> a
 const' x _ = x
 }}}

 {{{
 Not in scope: type variable ‘b’
 }}}

 One would expect the type variable introduced by the TH splice to be
 included in the implicit quantification of the type signature.

 In fact, there is no way to introduce a new type variable in this context,
 apart from using {{{Rank(2/N)Types}}} with an explicit {{{forall}}}. But
 this prevents the type variable from being referred to elsewhere in the
 type, eg:

 {{{
 const'' :: [tv|a|] -> b -> [tv|a|]
 const'' x _ = x
 }}}

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


More information about the ghc-tickets mailing list