blob: dba194c4ad6815b203518fe44902e5a555d16bf0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{-# LANGUAGE TemplateHaskell #-}
module Bug679 where
import Language.Haskell.TH
data Bar a = Bar
$(do
a <- newName "a"
let classN = mkName "Foo"
let methodN = mkName "foo"
methodTy <- [t| $(varT a) -> $(varT a) |]
let cla = ClassD [] classN [PlainTV a] [] [SigD methodN methodTy]
-- Note that we are /reusing/ the same type variable 'a' as in the class
instanceHead <- [t| $(conT classN) (Bar $(varT a)) |]
idCall <- [e| id |]
let ins = InstanceD Nothing [] instanceHead [FunD methodN [Clause [] (NormalB idCall) []]]
pure [cla,ins])
|