hackett
hackett copied to clipboard
Auto-derived Show instance not terminating
Running this program (or just running (show q)
in a REPL) never terminates.
#lang hackett
(data (Cons a b)
Nil
(Cons a (Cons b a))
#:deriving [Show])
(def q
(Cons 1
(Cons "3"
Nil)))
(main
(println (show q)))```
I think this is essentially the same bug as #89, but I’m not completely sure. The issue seems to be that, when solving Show (Cons b a)
, the typechecker isn’t smart enough to realize it doesn’t need to solve Show (Cons a b)
again, since that’s the constraint it’s currently solving, and it should simply tie the knot instead.
Yeah, I thought #89 looked similar but wasn't sure because that one involved a more complicated situation (classes + instances) while this was a fairly simple datatype.