I think you put your finger on the problem here. That `evalP` is a placeholder to get transformed away later. I thought that my `NOINLINE` annotation would prevent GHC from noticing that `evalP` evaluates to bottom. I'll do a better job.

Thank you!

-- Conal


On Fri, Mar 11, 2016 at 4:06 PM, Ömer Sinan Ağacan <omeragacan@gmail.com> wrote:
Empty case expressions like `case evalP @ (Pair Int) ds of wild { }` are only
valid if the scrutinee is bottom, see CoreLint.hs for how exprIsBottom is used
and CoreUtils.hs for how it's defined. So it seems like the simplifier somehow
figured that `evalP @ (Pair Int) ds` is bottom, and generated an empty case.

Is the linter complaining about this case expression? (you can try it using
CoreLint.lintExpr)

2016-03-11 16:49 GMT-05:00 Conal Elliott <conal@conal.net>:
>
> I'm working on a GHC plugin, mainly in the form of a "builtin" rewrite rule,
> and I'm seeing a strange disappearance of a case alternative. With
> -ddump-rule-rewrites, I can see before & after the disappearance: Here's one
> rule firing with the alternative present:
>
>     Rule fired
>         Rule: reify
>         Before: reifyP
>                   TyArg Pair Int -> Int
>                   ValArg \ (ds :: Pair Int) ->
>                            case ds of _ { :# a b -> $fNumInt_$c+ a b }
>         After:  lamP
>                   @ (Pair Int)
>                   @ Int
>                   "ds"#
>                   (\ (ds :: EP (Pair Int)) ->
>                      reifyP
>                        @ Int
>                        (case evalP @ (Pair Int) ds of _ { :# a b ->
> $fNumInt_$c+ a b }))
>         Cont:   StrictArg toE
>                 Stop[BoringCtxt] E Prim (Pair Int -> Int)
>
> The next thing I see is the rule firing again on the residual reifyP
> application, but with the case alternative gone:
>
>     Rule fired
>         Rule: reify
>         Before: reifyP
>                   TyArg Int ValArg case evalP @ (Pair Int) ds of wild { }
>         After:  ...
>
> Any ideas what's causing the disappearance?
>
> Thanks.  - Conal
>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>