TmOracle: Replace negative term equalities by refutable PmAltCons
The `PmExprEq` business was a huge hack and was at the same time vastly too powerful and not powerful enough to encode negative term equalities, i.e. facts of the form "forall y. x ≁ Just y". This patch introduces the concept of 'refutable shapes': What matters for the pattern match checker is being able to encode knowledge of the kind "x can no longer be the literal 5" or "x can no longer be Just y, for any y". We encode this knowledge in a `PmRefutEnv`, mapping a set of newly introduced `PmAltCon`s (literals and `ConLike`s) to eac variable denoting above inequalities. So, say we have `x ≁ Just ∈ refuts` in the term oracle context and try to solve an equality like `x ~ Just 5`. The entry in the refutable environment will immediately lead to a contradiction. This machinery renders the whole `PmExprEq` business unnecessary, getting rid of a lot of (mostly dead) code. Note that the `PmAltConLike` case is currently unnecessary: The `ConVar` case will just split the value set abstraction for each possible constructor instead of encoding negative equalites. This is bound to change in a follow-up patch. If we began to use `PmAltConLike`, we'd even profit from nicer error messages as is currently the case for negative literal equalities. See the Note [Refutable shapes] in TmOracle for a place to start.
parent
c931f256
No related branches found
No related tags found
Pipeline #6078 passed with warnings
Stage: lint
Stage: build
Stage: full-build
Stage: cleanup
Stage: packaging
Stage: hackage
Showing
- compiler/basicTypes/NameEnv.hs 4 additions, 0 deletionscompiler/basicTypes/NameEnv.hs
- compiler/deSugar/Check.hs 16 additions, 39 deletionscompiler/deSugar/Check.hs
- compiler/deSugar/PmExpr.hs 39 additions, 204 deletionscompiler/deSugar/PmExpr.hs
- compiler/deSugar/PmPpr.hs 192 additions, 0 deletionscompiler/deSugar/PmPpr.hs
- compiler/deSugar/TmOracle.hs 206 additions, 128 deletionscompiler/deSugar/TmOracle.hs
- compiler/ghc.cabal.in 1 addition, 0 deletionscompiler/ghc.cabal.in
- compiler/utils/ListSetOps.hs 8 additions, 1 deletioncompiler/utils/ListSetOps.hs
Loading
Please register or sign in to comment