summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T3899a.hs
blob: a63c17b0d324f18052df840b424ac1a0c17fd58b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{-# LANGUAGE TemplateHaskell #-}
module T3899a where


import Language.Haskell.TH
import Control.Monad

data Cons a b = Cons a b
data Nil = Nil

nestedTuple n = do
     xs <- replicateM n (newName "x")
     return $ LamE [foldr (\v prev -> ParensP (ConP 'Cons [VarP v,prev]))
                       (ConP 'Nil []) xs]
                   (TupE $ map (Just . VarE) xs)