Commit f07f8197 authored by igloo's avatar igloo

[project @ 2004-06-01 23:22:33 by igloo]

Add missing functions to TH export list (mostly spotted by Duncan Coutts).

Update TH test output.

Add TH support for patterns with type signatures, and test for same
(requested by Isaac Jones).

Add TH support for pattern guards, and tests for same
(requested by Isaac Jones).

Add infix patterns to TH datatypes.

Added Lift instances for 2- to 7-tuples (requested by Duncan Coutts).
parent c4ffa654
......@@ -6,11 +6,11 @@ TH_reifyDecl1.hs:33:9:
TH_reifyDecl1.hs:33:9:
data TH_reifyDecl1.List a_0 = TH_reifyDecl1.Nil
| TH_reifyDecl1.Cons a_0 TH_reifyDecl1.List a_0
| TH_reifyDecl1.Cons a_0 (TH_reifyDecl1.List a_0)
TH_reifyDecl1.hs:33:9:
data TH_reifyDecl1.Tree a_0 = TH_reifyDecl1.Leaf
| TH_reifyDecl1.:+: TH_reifyDecl1.Tree a_0 TH_reifyDecl1.Tree a_0
| TH_reifyDecl1.:+: (TH_reifyDecl1.Tree a_0) (TH_reifyDecl1.Tree a_0)
TH_reifyDecl1.hs:33:9: type TH_reifyDecl1.IntList = GHC.Base.[] GHC.Base.Int
......@@ -22,8 +22,8 @@ TH_reifyDecl1.hs:33:9:
TH_reifyDecl1.hs:33:9:
Class op from TH_reifyDecl1.C: TH_reifyDecl1.m :: forall a_0 . TH_reifyDecl1.C a_0 => a_0 ->
GHC.Base.Int
infixl 3 TH_reifyDecl1.m
GHC.Base.Int
infixl 3 TH_reifyDecl1.m
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
{-# OPTIONS -fglasgow-exts #-}
-- test the representation of unboxed literals
module Main
where
import Language.Haskell.TH
$(
do ds <- [d|
foo :: Int -> Int
foo x
| x == 5 = 6
foo x = 7
|]
runIO $ putStrLn $ pprint ds
return ds
)
$(
do ds <- [d|
bar :: Maybe Int -> Int
bar x
| Just y <- x = y
bar _ = 9
|]
runIO $ putStrLn $ pprint ds
return ds
)
main :: IO ()
main = do putStrLn $ show $ foo 5
putStrLn $ show $ foo 8
putStrLn $ show $ bar (Just 2)
putStrLn $ show $ bar Nothing
foo :: GHC.Base.Int -> GHC.Base.Int
foo x_0 | x_0 GHC.Base.== 5 = 6
foo x_1 = 7
bar :: Data.Maybe.Maybe GHC.Base.Int -> GHC.Base.Int
bar x_0 | Data.Maybe.Just y_1 <- x_0
= y_1
bar _ = 9
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
{-# OPTIONS -fglasgow-exts #-}
-- test the representation of unboxed literals
module Main
where
$(
[d|
foo :: Int -> Int
foo x
| x == 5 = 6
foo x = 7
|]
)
$(
[d|
bar :: Maybe Int -> Int
bar x
| Just y <- x = y
bar _ = 9
|]
)
main :: IO ()
main = do putStrLn $ show $ foo 5
putStrLn $ show $ foo 8
putStrLn $ show $ bar (Just 2)
putStrLn $ show $ bar Nothing
{-# OPTIONS -fglasgow-exts #-}
-- test the representation of unboxed literals
module Main
where
import Language.Haskell.TH
$(
[d|
foo :: Int -> Int
foo (x :: Int) = x
|]
)
main :: IO ()
main = return ()
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
AppE (ConE GHC.Base.I#) (LitE (IntPrimL 20))
GHC.Base.I# 20#
AppE (ConE GHC.Float.F#) (LitE (FloatPrimL (123 % 10)))
AppE (ConE GHC.Float.F#) (LitE (FloatPrimL (123%10)))
GHC.Float.F# 12.3#
AppE (ConE GHC.Float.D#) (LitE (DoublePrimL (123 % 5)))
AppE (ConE GHC.Float.D#) (LitE (DoublePrimL (123%5)))
GHC.Float.D# 24.6##
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
......
......@@ -9,6 +9,9 @@ test('TH_repE2', normal, compile_and_run, [''])
test('TH_repE3', normal, compile, [''])
test('TH_repPrim', normal, compile, [''])
test('TH_repPrimOutput', normal, compile_and_run, [''])
test('TH_repGuard', normal, compile, [''])
test('TH_repGuardOutput', normal, compile_and_run, [''])
test('TH_repPatSig', normal, compile, [''])
test('TH_reifyDecl1', 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