summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T11721_TH.hs
blob: a0624274529ea075031e0b05cbea2893519f3e3c (plain)
1
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
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module T11721_TH where

import Language.Haskell.TH

data T a where
  MkT :: forall b a. b -> T a

$(return [])

main :: IO ()
main = print
  $(do let rightOrder :: [TyVarBndr flag] -> Bool
           rightOrder [KindedTV b _ _, KindedTV a _ _]
             = nameBase b == "b" && nameBase a == "a"
           rightOrder _ = False

       TyConI (DataD _ _ _ _
                     [ForallC con_tvbs1 _ _] _) <- reify ''T
       DataConI _ (ForallT con_tvbs2 _ _) _ <- reify 'MkT

       if rightOrder con_tvbs1 && rightOrder con_tvbs2
          then [| () |]
          else fail "T11721_TH failed")