blob: 7219b7a200f5123ede9b2a334e3c35164bf7ef7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
{-# LANGUAGE Safe #-}
{-# LANGUAGE TemplateHaskell #-}
module SafeLang12_B ( Class(..), mkSimpleClass ) where
import Language.Haskell.TH
class Class a where
c :: a
mkSimpleClass :: Name -> Q [Dec]
mkSimpleClass name = do
TyConI (DataD [] dname [] Nothing cs _) <- reify name
((NormalC conname []):_) <- return cs
ClassI (ClassD [] cname [_] [] [SigD mname _]) _ <- reify ''Class
return [InstanceD Nothing [] (AppT (ConT cname) (ConT dname)) [FunD mname
[Clause [] (NormalB (ConE conname)) []]]]
|