summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/th/T1835.hs
blob: 296bf907ab12432df6f2e712cd1d9353b4960f76 (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
28
29
30
31
32
33
34
35
36
37
{-# LANGUAGE TemplateHaskell, FlexibleInstances,
          MultiParamTypeClasses, TypeSynonymInstances #-}
module Main where

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

class Eq a => MyClass a 
data Foo = Foo deriving Eq

instance MyClass Foo 

data Bar = Bar
  deriving Eq

type Baz = Bar
instance MyClass Baz

data Quux a  = Quux a   deriving Eq
data Quux2 a = Quux2 a  deriving Eq
instance Eq a  => MyClass (Quux a)
instance Num a => MyClass (Quux2 a)

class MyClass2 a b
instance MyClass2 Int Bool

main = do
    putStrLn $(do { info <- reify ''MyClass; lift (pprint info) })
    print $(isClassInstance ''Eq [ConT ''Foo] >>= lift)
    print $(isClassInstance ''MyClass [ConT ''Foo] >>= lift)
    print $ not $(isClassInstance ''Show [ConT ''Foo] >>= lift)
    print $(isClassInstance ''MyClass [ConT ''Bar] >>= lift) -- this one
    print $(isClassInstance ''MyClass [ConT ''Baz] >>= lift)
    print $(isClassInstance ''MyClass [AppT (ConT ''Quux) (ConT ''Int)] >>= lift) --this one
    print $(isClassInstance ''MyClass [AppT (ConT ''Quux2) (ConT ''Int)] >>= lift) -- this one
    print $(isClassInstance ''MyClass2 [ConT ''Int, ConT ''Bool] >>= lift)
    print $(isClassInstance ''MyClass2 [ConT ''Bool, ConT ''Bool] >>= lift)