summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_reifyGlobalDefs.hs
blob: d909b579d25d29dab6ec2d6415467c1c4363ec47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- test reification of global definitions
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH.Syntax
import System.IO


g :: Int
g = 1

main :: IO ()
main =
    $(do
      let printTypeOf n = do
            addModFinalizer $ do
              VarI _ t _ <- reify (mkName n)
              runIO $ hPutStrLn stderr (n ++ " :: " ++ show t)
      printTypeOf "g"
      ds <- [d| f = True |]
      addTopDecls ds
      printTypeOf "f"
      [| return () |]
     )