
#14832: QuantifiedConstraints: Adding to the context causes failure -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: | QuantifiedConstraints wipT2893 Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
The original program still gives a stack overflow with latest changes.
And so it should. You have a "given" `(Trans rel)`, where {{ type Trans rel = (forall xx yy zz. (rel xx yy, rel yy zz) => rel xx zz :: Constraint) }}} So if you want to solve `[W] rel t1 t2` (for some type `t1` or `t2`, this local instance (quantified constraint) matches. We can solve it by solving {{{ [W] rel t1 alpha [W] rel alpha t2 }}} where `alpha` is a fresh unification variable (corresponding to `yy` in the definition of `Trans rel`. But then each of those two constraints can be solved once more with this over-general local instance -- and now we hare four constraints. And so on. You used `UndecidableInstances` and sure enough you wrote an infinite loop. I say there is no bug here. The same thing wold happen if you wrote {{{ instance (C a x, C x b) => C a b }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14832#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler