diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-01-05 09:59:59 -0800 |
---|---|---|
committer | Alexander Biehl <alexbiehl@gmail.com> | 2018-02-01 14:58:18 +0100 |
commit | 6ed6c110c874a746b002aca148192c3cbc819d7f (patch) | |
tree | 0bd3be02e0b402affbc474fd695db523021772ab /html-test/src | |
parent | 9fd7f8bff6bdb6459fbecdc02db09789cfb6c816 (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')
-rw-r--r-- | html-test/src/Bug679.hs | 24 |
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]) + |