[GHC] #12818: Allow reify to find top-level bindings in later declaration groups

GHC ghc-devs at haskell.org
Wed Nov 9 13:52:04 UTC 2016


#12818: Allow reify to find top-level bindings in later declaration groups
-------------------------------------+-------------------------------------
           Reporter:                 |             Owner:
  facundo.dominguez                  |
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.0.1
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):  Phab:D2519     |         Wiki Page:
-------------------------------------+-------------------------------------
 Some time ago, at Tweag we were considering inspecting the types of
 declarations added with `addTopDecls` like this:

 {{{
 {-# LANGUAGE TemplateHaskell #-}
 import Language.Haskell.TH.Syntax

 main :: IO ()
 main =
     $(do
       ds <- [d| f = True |]
       addTopDecls ds
       addModFinalizer $ do
         VarI _ t _ <- reify (mkName "f")
         runIO $ hPutStrLn stderr ("f :: " ++ show t)
       [| return () |]
      )
 }}}
 `f` is not in scope when the finalizer is added. But its type would be
 known when the finalizer runs.

 This worked before the patch https://phabricator.haskell.org/D2286.
 There is a patch that we submitted to address this
 https://phabricator.haskell.org/D2519, but it turned out later that we
 didn't need it and the patch was considered less than ideal.

 We are opening this ticket to keep track of the nuance in case someone
 finds the patch useful later.

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


More information about the ghc-tickets mailing list