[GHC] #10166: GHCi: internal error: stg_ap_p_ret

GHC ghc-devs at haskell.org
Tue Mar 17 22:08:36 UTC 2015


#10166: GHCi: internal error: stg_ap_p_ret
-------------------------------------+-------------------------------------
        Reporter:  andreas.abel      |                   Owner:
            Type:  bug               |                  Status:  closed
        Priority:  normal            |               Milestone:
       Component:  GHCi              |                 Version:  7.8.4
      Resolution:  invalid           |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by monoidal):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Letting X be a shortcut for `Const (Suc (Suc Zero))`, your program makes
 an evaluation step

 {{{
 eval (App Pred X) => coerce $ evalP (App Pred X)`
 }}}

 and attempts to print this as a `Nat`, but `evalP (App Pred X)` is a
 function (evalP takes two arguments), that's an invalid coercion.

 If you change your `eval` to

 {{{#!hs
 eval :: Exp -> a
 eval (Const n) = coerce n
 eval Pred      = coerce pr
 eval (App f e) = coerce (eval f (eval e))

 pr Zero = Zero
 pr (Succ n) = n
 }}}

 then it works on my machine, but you should use `Any` for such tricks
 (https://hackage.haskell.org/package/ghc-prim-0.3.1.0/docs/GHC-
 Prim.html#v:unsafeCoerce35-).

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


More information about the ghc-tickets mailing list