summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs
blob: f6ce559448bb380aa6687473f1357d9ee86c7913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{-# LANGUAGE Safe #-}
{-# LANGUAGE TemplateHaskell #-}
module SafeLang11_B ( Class(..), mkSimpleClass ) where

import Language.Haskell.TH

class Class a where
	c :: a

mkSimpleClass :: Name -> Q [Dec]
mkSimpleClass name = do
	TyConI (DataD [] dname [] cs _) <- reify name
	((NormalC conname []):_) <- return cs
	ClassI (ClassD [] cname [_] [] [SigD mname _]) _ <- reify ''Class
	return [InstanceD [] (AppT (ConT cname) (ConT dname)) [FunD mname
            [Clause [] (NormalB (ConE conname)) []]]]