[Git][ghc/ghc][master] 3 commits: SimpleOpt: refactor & push coercions into lambdas
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 15b311be by sheaf at 2025-11-15T20:32:02-05:00 SimpleOpt: refactor & push coercions into lambdas This commit improves the simple optimiser (in GHC.Core.SimpleOpt) in a couple of ways: - The logic to push coercion lambdas is shored up. The function 'pushCoercionIntoLambda' used to be called in 'finish_app', but this meant we could not continue to optimise the program after performing this transformation. Now, we call 'pushCoercionIntoLambda' as part of 'simple_app'. Doing so can be important when dealing with unlifted newtypes, as explained in Note [Desugaring unlifted newtypes]. - The code is re-structured to avoid duplication and out-of-sync code paths. Now, 'simple_opt_expr' defers to 'simple_app' for the 'App', 'Var', 'Cast' and 'Lam' cases. This means all the logic for those is centralised in a single place (e.g. the 'go_lam' helper function). To do this, the general structure is brought a bit closer to the full-blown simplifier, with a notion of 'continuation' (see 'SimpleContItem'). This commit also modifies GHC.Core.Opt.Arity.pushCoercionIntoLambda to apply a substitution (a slight generalisation of its existing implementation). - - - - - b33284c7 by sheaf at 2025-11-15T20:32:02-05:00 Improve typechecking of data constructors This commit changes the way in which we perform typecheck data constructors, in particular how we make multiplicities line up. Now, impedance matching occurs as part of the existing subsumption machinery. See the revamped Note [Typechecking data constructors] in GHC.Tc.Gen.App, as well as Note [Polymorphisation of linear fields] in GHC.Core.Multiplicity. This allows us to get rid of a fair amount of hacky code that was added with the introduction of LinearTypes; in particular the logic of GHC.Tc.Gen.Head.tcInferDataCon. ------------------------- Metric Decrease: T10421 T14766 T15164 T15703 T19695 T5642 T9630 WWRec ------------------------- - - - - - b6faf5d0 by sheaf at 2025-11-15T20:32:02-05:00 Handle unsaturated rep-poly newtypes This commit allows GHC to handle unsaturated occurrences of unlifted newtype constructors. The plan is detailed in Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Utils.Concrete: for unsaturated unlifted newtypes, we perform the appropriate representation-polymorphism check in tcInstFun. - - - - - 65 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/FVs.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs-boot - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/Concrete.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/diagnostic-codes/codes.stdout - testsuite/tests/ghci/scripts/T8959b.stderr - testsuite/tests/ghci/scripts/ghci051.stderr - testsuite/tests/indexed-types/should_compile/T12538.stderr - + testsuite/tests/linear/should_compile/LinearEtaExpansions.hs - testsuite/tests/linear/should_compile/all.T - testsuite/tests/linear/should_fail/TypeClass.hs - testsuite/tests/linear/should_fail/TypeClass.stderr - testsuite/tests/linear/should_run/LinearGhci.stdout - testsuite/tests/numeric/should_compile/T16402.stderr-ws-64 - testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr - testsuite/tests/perf/compiler/all.T - testsuite/tests/rep-poly/RepPolyCase1.stderr - − testsuite/tests/rep-poly/RepPolyCase2.stderr - testsuite/tests/rep-poly/RepPolyRule3.stderr - testsuite/tests/rep-poly/RepPolyTuple4.stderr - testsuite/tests/rep-poly/T13233.stderr - − testsuite/tests/rep-poly/T17021.stderr - testsuite/tests/rep-poly/T20363b.stderr - − testsuite/tests/rep-poly/T21650_a.stderr - − testsuite/tests/rep-poly/T21650_b.stderr - + testsuite/tests/rep-poly/T26072.hs - testsuite/tests/rep-poly/UnliftedNewtypesLevityBinder.stderr - testsuite/tests/rep-poly/all.T - testsuite/tests/typecheck/should_fail/T15883e.stderr - testsuite/tests/typecheck/should_fail/T2414.stderr - testsuite/tests/typecheck/should_fail/T2534.stderr - testsuite/tests/typecheck/should_fail/T7264.stderr - utils/haddock/hypsrc-test/ref/src/Classes.html - utils/haddock/hypsrc-test/ref/src/Quasiquoter.html The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a64a78bc91a57868195d596d98ebbd... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0a64a78bc91a57868195d596d98ebbd... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)