[Git][ghc/ghc][wip/pmcheck-eqs] Make TmOracle reduce nullary constructor equalities

Sebastian Graf gitlab at gitlab.haskell.org
Mon May 20 15:27:50 UTC 2019



Sebastian Graf pushed to branch wip/pmcheck-eqs at Glasgow Haskell Compiler / GHC


Commits:
b60b1cac by Sebastian Graf at 2019-05-20T15:27:31Z
Make TmOracle reduce nullary constructor equalities

Previously, `simplifyEqExpr` would just give up on constructor
applications when no argument to either constructor was simplified.

That's unfortunate as all arguments might be equal anyway! A special
case of this is nullary constructors. Currently, the TmOracle would fail
to solve a term equality `False ~ (True = True)` because it can't make
any progress on any of `True`s arguments.

Instead we now try to properly simplify the term equality even when no
simplification of constructor arguments was achieved.

- - - - -


1 changed file:

- compiler/deSugar/TmOracle.hs


Changes:

=====================================
compiler/deSugar/TmOracle.hs
=====================================
@@ -208,10 +208,9 @@ simplifyEqExpr e1 e2 = case (e1, e2) of
             (ts2', bs2) = mapAndUnzip simplifyPmExpr ts2
             (tss, _bss) = zipWithAndUnzip simplifyEqExpr ts1' ts2'
             worst_case  = PmExprEq (PmExprCon c1 ts1') (PmExprCon c2 ts2')
-        in  if | not (or bs1 || or bs2) -> (worst_case, False) -- no progress
-               | all isTruePmExpr  tss  -> (truePmExpr, True)
+        in  if | all isTruePmExpr  tss  -> (truePmExpr, True)
                | any isFalsePmExpr tss  -> (falsePmExpr, True)
-               | otherwise              -> (worst_case, False)
+               | otherwise              -> (worst_case, or bs1 || or bs2)
     | otherwise -> (falsePmExpr, True)
 
   -- We cannot do anything about the rest..



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/b60b1cac6f6503f3f9df6f250c8cf17e904fe1f5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/b60b1cac6f6503f3f9df6f250c8cf17e904fe1f5
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190520/598fbac1/attachment.html>


More information about the ghc-commits mailing list