summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T9022.hs
blob: 9c676aa7d0cceab8f1d1a355bde8e65f8273b33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Main where

import Language.Haskell.TH

main = putStrLn $ pprint foo

foo :: Dec
foo = barD
  where
       barD = FunD ( mkName "bar" )
                   [ Clause manyArgs (NormalB barBody) [] ]

       barBody = DoE Nothing [letxStmt, retxStmt]
       letxStmt = LetS [ ValD (VarP xName) (NormalB $ LitE $ IntegerL 5) [] ]
       retxStmt = NoBindS $ AppE returnVarE xVarE
       xName = mkName "x"
       returnVarE = VarE $ mkName "return"
       xVarE = VarE xName
       manyArgs = map argP [0..9]
       argP n = VarP $ mkName $ "arg" ++ show n