Commit 43a4dd0d authored by igloo's avatar igloo

[project @ 2003-05-03 22:11:52 by igloo]

Update testsuite in line with recent TH changes.

Added a couple of cases to TH_repE1 and added a new TH_repE2 that also
splices things back in and checks they can be printed correctly.
parent 94a5678f
......@@ -8,23 +8,23 @@ import Language.Haskell.THSyntax
-- simple
data T = A | B
decl_T :: Decl
decl_T :: DecQ
decl_T = reifyDecl T
-- parametric
data R a = C a | D
decl_R :: Decl
decl_R :: DecQ
decl_R = reifyDecl R
-- recursive
data List a = Nil | Cons a (List a)
decl_List :: Decl
decl_List :: DecQ
decl_List = reifyDecl List
-- infix operator
data Tree a = Leaf | Tree a :+: Tree a
decl_Tree :: Decl
decl_Tree :: DecQ
decl_Tree = reifyDecl Tree
......@@ -8,5 +8,5 @@ import Language.Haskell.THSyntax
-- type declaration
type IntList = [Int]
decl_IntList :: Decl
decl_IntList :: DecQ
decl_IntList = reifyDecl IntList
......@@ -8,5 +8,5 @@ import Language.Haskell.THSyntax
-- newtype declaration
newtype Length = Length Int
decl_Length :: Decl
decl_Length :: DecQ
decl_Length = reifyDecl Length
......@@ -9,5 +9,5 @@ import Language.Haskell.THSyntax
class C a where
m :: a -> Int
decl_C :: Decl
decl_C :: DecQ
decl_C = reifyDecl C
......@@ -8,6 +8,6 @@ import Language.Haskell.THSyntax
foo :: Int -> Int
foo x = x + 1
type_foo :: Type
type_foo :: TypQ
type_foo = reifyType foo
......@@ -5,5 +5,5 @@ where
import Language.Haskell.THSyntax
type_length :: Type
type_length :: TypQ
type_length = reifyType length
......@@ -5,20 +5,26 @@ where
import Language.Haskell.THSyntax
intExpr :: Expr
integralExpr :: ExpQ
integralExpr = [| 42 |]
intExpr :: ExpQ
intExpr = [| 42 :: Int |]
integerExpr :: Expr
integerExpr :: ExpQ
integerExpr = [| 42 :: Integer |]
charExpr :: Expr
charExpr :: ExpQ
charExpr = [| 'x' |]
stringExpr :: Expr
stringExpr :: ExpQ
stringExpr = [| "A String" |]
floatExpr :: Expr
fractionalExpr :: ExpQ
fractionalExpr = [| 1.2 |]
floatExpr :: ExpQ
floatExpr = [| 1.2 :: Float |]
doubleExpr :: Expr
doubleExpr :: ExpQ
doubleExpr = [| 1.2 :: Double |]
-- test the representation of literals and also explicit type annotations
module Main
where
import Language.Haskell.THSyntax
main :: IO ()
main = mapM_ putStrLn [show an_integral, show an_int, show an_integer,
show an_char, show an_string, show an_fractional,
show an_float, show an_double]
an_integral :: Integer
an_integral = $( [| 42 |] )
an_int :: Int
an_int = $( [| 42 :: Int |] )
an_integer :: Integer
an_integer = $( [| 98765432123456789876 :: Integer |] )
an_char :: Char
an_char = $( [| 'x' |] )
an_string :: String
an_string = $( [| "A String" |] )
an_fractional :: Double
an_fractional = $( [| 1.2 |] )
an_float :: Float
an_float = $( [| 1.2 :: Float |] )
an_double :: Double
an_double = $( [| 1.2 :: Double |] )
42
42
98765432123456789876
'x'
"A String"
1.2
1.2
1.2
......@@ -7,4 +7,4 @@ import Language.Haskell.THSyntax
-- splice a simple data declaration
$(return [Data "T" [] [Constr "C" []] []])
$(return [Data [] "T" [] [Constr "C" []] []])
......@@ -4,8 +4,8 @@ where
import Language.Haskell.THSyntax
rename' :: Dec -> Q [Dec]
rename' (Data tyName tyvars cons derivs) =
return [Data (stripMod tyName ++ "'") tyvars (map renameCons cons) derivs]
rename' (Data cxt tyName tyvars cons derivs) =
return [Data cxt (stripMod tyName ++ "'") tyvars (map renameCons cons) derivs]
where
renameCons (Constr conName tys) = Constr (stripMod conName ++ "'") tys
--
......
......@@ -5,6 +5,7 @@ setTestOpts(f)
setTestOpts(only_ways(['normal']));
test('TH_repE1', normal, compile, [''])
test('TH_repE2', normal, compile_and_run, [''])
test('TH_reifyDecl1', normal, compile, [''])
test('TH_reifyDecl2', normal, compile, [''])
......
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