
Simon Peyton Jones pushed to branch wip/T23109 at Glasgow Haskell Compiler / GHC Commits: b02d4987 by Simon Peyton Jones at 2025-06-11T16:56:18+01:00 wibbles - - - - - 3 changed files: - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/HsToCore/Binds.hs Changes: ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -1900,12 +1900,15 @@ Suppose we have a function with a complicated type: and suppose it is called at: - f 7 @T1 @T2 @T3 dEqT1 ($dfShow dShowT2) t3 + f @T1 @T2 @T3 7 dEqT1 ($dfShow dShowT2) t3 This call is described as a 'CallInfo' whose 'ci_key' is: - [ SpecType T1, SpecType T2, UnspecType, UnspecArg, SpecDict dEqT1 - , SpecDict ($dfShow dShowT2), UnspecArg ] + [ SpecType T1, SpecType T2, UnspecType + , UnspecArg + , SpecDict dEqT1 + , SpecDict ($dfShow dShowT2) + , UnspecArg ] Why are 'a' and 'b' identified as 'SpecType', while 'c' is 'UnspecType'? Because we must specialise the function on type variables that appear ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -197,6 +197,9 @@ specUnfolding opts spec_bndrs spec_app rule_lhs_args spec_app (mkLams old_bndrs arg) -- The beta-redexes created by spec_app will be -- simplified away by simplOptExpr + -- ToDo: this is VERY DELICATE for type args. We make + -- (\@a @b x y. TYPE ty) ty1 ty2 d1 d2 + -- and rely on it simplifyign to ty[ty1/a, ty2/b] specUnfolding opts spec_bndrs spec_app rule_lhs_args (CoreUnfolding { uf_src = src, uf_tmpl = tmpl ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -1113,7 +1113,9 @@ dsSpec_help poly_nm poly_id poly_rhs inl bndrs ds_call spec_bndrs = filterOut (`elemVarSet` const_bndrs) rule_bndrs mk_spec_body fn_body = mkLets spec_const_binds $ - mkCoreApps fn_body rule_lhs_args + mkApps fn_body rule_lhs_args + -- ToDo: not mkCoreApps! That uses exprType on fun which + -- fails in specUnfolding, sigh ; tracePm "dsSpec(new route)" $ vcat [ text "poly_id" <+> ppr poly_id View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b02d4987d3ab1ce4816f72055f099782... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b02d4987d3ab1ce4816f72055f099782... You're receiving this email because of your account on gitlab.haskell.org.