SafeLang11_B.hs 494 Bytes
Newer Older
dterei's avatar
dterei committed
1 2 3 4 5 6 7 8 9 10
{-# 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
11
	TyConI (DataD [] dname [] Nothing cs _) <- reify name
dterei's avatar
dterei committed
12 13
	((NormalC conname []):_) <- return cs
	ClassI (ClassD [] cname [_] [] [SigD mname _]) _ <- reify ''Class
14
	return [InstanceD Nothing [] (AppT (ConT cname) (ConT dname)) [FunD mname
dterei's avatar
dterei committed
15 16
            [Clause [] (NormalB (ConE conname)) []]]]