hackett icon indicating copy to clipboard operation
hackett copied to clipboard

Auto-derived Show instance not terminating

Open fiddlerwoaroof opened this issue 6 years ago • 2 comments

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)))```

fiddlerwoaroof avatar Oct 17 '18 03:10 fiddlerwoaroof

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.

lexi-lambda avatar Oct 18 '18 01:10 lexi-lambda

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.

fiddlerwoaroof avatar Oct 29 '18 16:10 fiddlerwoaroof