Disappearing case alternative?

Ömer Sinan Ağacan omeragacan at gmail.com
Sat Mar 12 00:06:11 UTC 2016


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 at 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>


More information about the ghc-devs mailing list