[GHC] #15928: Reduction stack overflow when using "coerce"

GHC ghc-devs at haskell.org
Sat Nov 24 22:35:54 UTC 2018


#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 harendra):

 I am further puzzled, as we know already, this definition works fine:

 {{{
 data Stream m a =
     Stream {
         unStream :: forall r. (Stream m a -> m r) -> m r
     }
 }}}

 And this one results in an error:

 {{{
 data Stream (m :: * -> *) a = Stop | Yield a (Stream m a)
 }}}

 {{{
 xy.hs:26:20: error:
     • Couldn't match representation of type ‘a0’ with that of ‘a’
         arising from a use of ‘coerce’
       ‘a’ is a rigid type variable bound by
         the type signature for:
           f :: forall a. SerialT Identity a -> Identity Bool
         at xy.hs:25:1-40
     • In the second argument of ‘(.)’, namely ‘coerce’
       In the second argument of ‘(.)’, namely ‘idSerial . coerce’
       In the expression: g . idSerial . coerce
     • Relevant bindings include
         f :: SerialT Identity a -> Identity Bool (bound at xy.hs:26:1)
    |
 26 | f = g . idSerial . coerce
    |                    ^^^^^^
 }}}

 If there is no bug then this needs to be explained in some simple way.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15928#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list