[Git][ghc/ghc][master] Allow rewriting in RuntimeReps for newtype ConPats
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c77d88fc by sheaf at 2026-08-13T10:15:22-04:00 Allow rewriting in RuntimeReps for newtype ConPats This commit implements PHASE 2 of the FixedRuntimeRep plan described in Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete for newtype constructor patterns. In short, GHC now accepts programs of the form f (MkN x) = ... in which the argument 'x' of the newtype constructor pattern 'MkN x' has a representation that is not syntactically concrete, e.g. it can be 'Id IntRep' reducing to 'IntRep'. See T20363{,b,c} for examples. There are two main parts to the implementation: 1. Typechecking, in GHC.Tc.Gen.Pat.tcDataConPat. See Note [Typechecking newtype constructor patterns] in GHC.Tc.Gen.Pat. 2. Desugaring. We restructure the code for desugaring pattern matches by allowing the scrutinised match variable to be casted. This allows us to accumulate coercions and avoids creating binders at intermediate types tha don't have a fixed RuntimeRep. See the revamped Note [Match Ids] in GHC.HsToCore.Monad. Fixes #20363 ------------------------- Metric Increase: InstanceMatching ------------------------- - - - - - 32 changed files: - + changelog.d/T20363 - compiler/GHC/Hs/Pat.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Match.hs-boot - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/HsToCore/Match/Literal.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Concrete.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/corelint/T21115b.stderr - testsuite/tests/dmdanal/should_compile/T23398.stderr - testsuite/tests/numeric/should_compile/T23907.stderr - testsuite/tests/rep-poly/RepPolyRecordPattern.hs - testsuite/tests/rep-poly/RepPolyRecordPattern.stderr - testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr - testsuite/tests/rep-poly/T20113.stderr - − testsuite/tests/rep-poly/T20363.stderr - − testsuite/tests/rep-poly/T20363_show_co.hs - − testsuite/tests/rep-poly/T20363_show_co.stderr - − testsuite/tests/rep-poly/T20363b.stderr - + testsuite/tests/rep-poly/T20363c.hs - testsuite/tests/rep-poly/all.T - testsuite/tests/simplCore/should_compile/T24229a.stderr - testsuite/tests/simplCore/should_compile/T24229b.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4081.stderr - testsuite/tests/simplCore/should_compile/T4908.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c77d88fc84cc5ac065bf1b782de7720f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c77d88fc84cc5ac065bf1b782de7720f... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Marge Bot (@marge-bot)