summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs
blob: 50e7930c2d3a2602f4609a1c9997c93865ce728b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{-# LANGUAGE Haskell2010 #-}
{-# 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)) []]]]