Commit 83b1dbc0 authored by Ian Lynagh's avatar Ian Lynagh

Add a test for TH and unboxed tuples

parent 486294bf
{-# LANGUAGE TemplateHaskell, UnboxedTuples #-}
-- test the representation of unboxed tuples
module Main where
import GHC.Exts
import GHC.Float
import Language.Haskell.TH
import Text.PrettyPrint
import System.IO
main :: IO ()
main = case bar () of
(# str, int #) ->
print (str, int)
bar :: () -> (# String, Int #)
bar () = $( do e <- [| case (# 'b', False #) of
(# 'a', True #) -> (# "One", 1 #)
(# 'b', False #) -> (# "Two", 2 #)
(# _, _ #) -> (# "Three", 3 #)
|]
runIO $ putStrLn $ show e
runIO $ putStrLn $ pprint e
runIO $ hFlush stdout
return e )
CaseE (UnboxedTupE [LitE (CharL 'b'),ConE GHC.Types.False]) [Match (UnboxedTupP [LitP (CharL 'a'),ConP GHC.Types.True []]) (NormalB (UnboxedTupE [LitE (StringL "One"),LitE (IntegerL 1)])) [],Match (UnboxedTupP [LitP (CharL 'b'),ConP GHC.Types.False []]) (NormalB (UnboxedTupE [LitE (StringL "Two"),LitE (IntegerL 2)])) [],Match (UnboxedTupP [WildP,WildP]) (NormalB (UnboxedTupE [LitE (StringL "Three"),LitE (IntegerL 3)])) []]
case (# 'b', GHC.Types.False #) of
(# 'a', GHC.Types.True #) -> (# "One", 1 #)
(# 'b', GHC.Types.False #) -> (# "Two", 2 #)
(# _, _ #) -> (# "Three", 3 #)
......@@ -21,6 +21,7 @@ test('TH_repE2', normal, compile_and_run, [''])
test('TH_repE3', normal, compile, [''])
test('TH_repPrim', normal, compile, ['-v0'])
test('TH_repPrim2', normal, compile, ['-v0'])
test('TH_repUnboxedTuples', normal, compile, ['-v0'])
test('TH_spliceGuard', normal, compile, ['-v0'])
test('TH_repPrimOutput', normal, compile_and_run, [''])
test('TH_repPrimOutput2', normal, compile_and_run, [''])
......
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