summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T3845.hs
blob: 29dc51fbda8b220fd967e89201ea56e966872c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE TemplateHaskell #-}

module THBug1 where

import Language.Haskell.TH
import Language.Haskell.TH.Syntax

data HCons a b = HCons a b
data HNil = HNil

mhlt :: [Q Type] -> Q Type
mhlt xss = [t| $(foldThing xss)|]
  where
    foldThing (x:xs) = [t| HCons $x $(foldThing xs)|]
    foldThing []     = [t| HNil |]

mhlt1 :: [Int] -> Q Exp
mhlt1 xss = [| $(foldThing1 xss) |]
  where
    foldThing1 (x:xs) = [| x : $(foldThing1 xs)|]
    foldThing1 [] = [| [] |]