aboutsummaryrefslogtreecommitdiff
path: root/html-test/src/Bug679.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-01-05 09:59:59 -0800
committerAlexander Biehl <alexbiehl@gmail.com>2018-02-01 14:58:18 +0100
commit6ed6c110c874a746b002aca148192c3cbc819d7f (patch)
tree0bd3be02e0b402affbc474fd695db523021772ab /html-test/src/Bug679.hs
parent9fd7f8bff6bdb6459fbecdc02db09789cfb6c816 (diff)
Fix infinite loop when specializing instance heads (#723)
* Fix infinite loop when specializing instance heads The bug can only be triggered from TH, hence why it went un-noticed for so long. * Add test for #679 and #710
Diffstat (limited to 'html-test/src/Bug679.hs')
-rw-r--r--html-test/src/Bug679.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/html-test/src/Bug679.hs b/html-test/src/Bug679.hs
new file mode 100644
index 00000000..dba194c4
--- /dev/null
+++ b/html-test/src/Bug679.hs
@@ -0,0 +1,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])
+