Commit 4ccdc324 authored by gmainland's avatar gmainland

Adjust tests for new Template Haskell.

From the new Template Haskell proposal at
http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal

  A declaration group is the chunk of declarations created by a top-level
  declaration splice, plus those following it, down to but not including the
  next top-level declaration splice. Then the type environment seen by reify
  includes all the declaration up to the end of the immediately preceding
  declaration block, but no more.

This change adds '$(return [])' where necessary to allow following declarations
to see (module-local) top-level definitions.
parent c5806bf6
......@@ -24,6 +24,8 @@ instance Ord a => MyClass (Quux2 a)
class MyClass2 a b
instance MyClass2 Int Bool
$(return [])
main = do
putStrLn $(do { info <- reify ''MyClass; lift (pprint info) })
print $(isInstance ''Eq [ConT ''Foo] >>= lift)
......
......@@ -7,12 +7,16 @@ import System.IO
a = 1
$(return [])
b = $(do VarI _ t _ _ <- reify 'a
runIO $ putStrLn ("inside b: " ++ pprint t)
[| undefined |])
c = $([| True |])
$(return [])
d = $(do VarI _ t _ _ <- reify 'c
runIO $ putStrLn ("inside d: " ++ pprint t)
[| undefined |] )
......@@ -23,6 +27,8 @@ $(do VarI _ t _ _ <- reify 'c
e = $([| True |])
$(return [])
f = $(do VarI _ t _ _ <- reify 'e
runIO $ putStrLn ("inside f: " ++ pprint t)
[| undefined |] )
......
......@@ -5,6 +5,8 @@ import Language.Haskell.TH
type family S :: (* -> (* -> * -> *)) -> (* -> *) -> *
$(return [])
test :: String
test = $(do
test <- [d|
......
......@@ -9,6 +9,8 @@ t2 x = x
prop_x1 x = t1 x == t2 x
$(return [])
runTests = $( do VarI _ t _ _ <- reify (mkName "prop_x1")
error $ ("runTest called error: " ++ pprint t)
)
......@@ -10,6 +10,8 @@ instance C Int
type D a = C a
$(return [])
main = print $(
do isCInst <- isInstance ''C [ConT ''Int]
isDInst <- isInstance ''D [ConT ''Int]
......
......@@ -10,6 +10,8 @@ f = "TH_lookupName.f"
data D = D
$(return [])
main = mapM_ print [
-- looking up values
$(do { Just n <- lookupValueName "f" ; varE n }),
......
......@@ -60,6 +60,8 @@ data family DF1 a
data family DF2 a
data instance DF2 Bool = DBool
$(return [])
test :: ()
test = $(let
display :: Name -> Q ()
......
......@@ -28,6 +28,8 @@ data family D2 a
data instance D2 Int = DInt | DInt2
data instance D2 Bool = DBool
$(return [])
test :: ()
test = $(let
display :: Name -> Q ()
......
......@@ -8,6 +8,8 @@ data Tree = N
| Tree :+ Tree
| Tree :* Tree
$(return [])
-- Should fail
expr = $( let plus = conE '(:+)
n = conE 'N
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment