
#15928: Reduction stack overflow when using "coerce" -------------------------------------+------------------------------------- Reporter: harendra | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Actually the error message is quite informative, isn't it? It says that GHC is trying to solve {{{ Coercible ((Stream Identity a -> Identity r) -> Identity r) ((Stream Identity a0 -> Identity r) -> Identity r) }}} Well the `->` and `Identity` parts are easy. That leaves us with proving {{{ Coercible (Stream Identity a) (Stream Identity a0) }}} How can we do that? Aha! Unwrap the newtype (on both sides). That givs us {{{ Coercible (forall r. (Stream Identity a -> Identity r) -> Identity r) (forall r. (Stream Identity a0 -> Identity r) -> Identity r) }}} How can we prove that? Well, we can dive under the `forall` to give {{{ Coercible ((Stream Identity a -> Identity r) -> Identity r) ((Stream Identity a0 -> Identity r) -> Identity r) }}} And now we are back where we began. This known incompleteness is described in Section 5.3.1 of [https://www.microsoft.com/en- us/research/publication/safe-zero-cost-coercions-haskell/ Safe zero-cost coercions in Haskell]. I don't know how to solve it; the reduction-stack bound gives a decent diagnosis. I grant that what seems decent to me may seem very different to a Haskell programmer. But I don't yet know how to do better. Does the explanation help? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15928#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler