TH_ppr1.hs 828 Bytes
Newer Older
1
{-# LANGUAGE MultiParamTypeClasses #-}
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

module Main (main) where

import Language.Haskell.TH

u1 :: a
u1 = undefined

u2 :: a
u2 = undefined

f :: a
f = undefined

(.+.) :: a
(.+.) = undefined

main :: IO ()
main = do runQ [| f u1 u2 |] >>= p
          runQ [| u1 `f` u2 |] >>= p
          runQ [| (.+.) u1 u2 |] >>= p
          runQ [| u1 .+. u2 |] >>= p
          runQ [| (:) u1 u2 |] >>= p
          runQ [| u1 : u2 |] >>= p
          runQ [| \((:) x xs) -> x |] >>= p
          runQ [| \(x : xs) -> x |] >>= p
          runQ [d| class Foo a b where
                       foo :: a -> b   |] >>= p
Ian Lynagh's avatar
Ian Lynagh committed
30 31 32 33
          runQ [| \x -> (x, 1 `x` 2) |] >>= p
          runQ [| \(+) -> ((+), 1 + 2) |] >>= p
          runQ [| (f, 1 `f` 2) |] >>= p
          runQ [| ((.+.), 1 .+. 2) |] >>= p
34 35 36 37

p :: Ppr a => a -> IO ()
p = putStrLn . pprint