[GHC] #9262: Allow free variables in reifyInstances

GHC ghc-devs at haskell.org
Thu Jul 3 16:42:23 UTC 2014


#9262: Allow free variables in reifyInstances
------------------------------------+-------------------------------------
       Reporter:  goldfire          |             Owner:  goldfire
           Type:  feature request   |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Template Haskell  |           Version:  7.8.2
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 When I say

 {{{
 {-# LANGUAGE TemplateHaskell #-}

 module Bug where

 import Language.Haskell.TH

 $( do insts <- reifyInstances ''Eq [ListT `AppT` VarT (mkName "a")]
       runIO $ putStrLn $ pprint insts
       return [] )
 }}}

 I get

 {{{
 Bug.hs:7:4:
     Not in scope: type variable ‘a’
     In the argument of reifyInstances: GHC.Classes.Eq [a]
 }}}

 But, I wanted the declaration for `instance Eq a => Eq [a]`. The error
 message isn't wrong, exactly -- `a` really isn't in scope -- but I think
 we can do better by just treating variables as fresh.

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


More information about the ghc-tickets mailing list