diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-07-14 15:37:18 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-18 07:26:45 -0400 |
commit | e504c9137dff2b8f51e8ed96b5cbb5a0d19f8e3a (patch) | |
tree | 972f29baee5b3a27caf5d967c3518878b4e5b690 /compiler/GHC/Core.hs | |
parent | 12f9035200424ec8104484f154a040d612fee99d (diff) | |
download | haskell-e504c9137dff2b8f51e8ed96b5cbb5a0d19f8e3a.tar.gz |
Refactor the simplification of join binders
This MR (for #18449) refactors the Simplifier's treatment
of join-point binders.
Specifically, it puts together, into
GHC.Core.Opt.Simplify.Env.adjustJoinPointType
two currently-separate ways in which we adjust the type of
a join point. As the comment says:
-- (adjustJoinPointType mult new_res_ty join_id) does two things:
--
-- 1. Set the return type of the join_id to new_res_ty
-- See Note [Return type for join points]
--
-- 2. Adjust the multiplicity of arrows in join_id's type, as
-- directed by 'mult'. See Note [Scaling join point arguments]
I think this actually fixes a latent bug, by ensuring that the
seIdSubst and seInScope have the right multiplicity on the type
of join points.
I did some tidying up while I was at it. No more
setJoinResTy, or modifyJoinResTy: instead it's done locally in
Simplify.Env.adjustJoinPointType
Diffstat (limited to 'compiler/GHC/Core.hs')
-rw-r--r-- | compiler/GHC/Core.hs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/compiler/GHC/Core.hs b/compiler/GHC/Core.hs index bc61929ed4..a99a1adfd6 100644 --- a/compiler/GHC/Core.hs +++ b/compiler/GHC/Core.hs @@ -798,15 +798,18 @@ and case-of-case] in GHC.Core.Opt.Simplify): in jump j z w -The body of the join point now returns a Bool, so the label `j` has to have its -type updated accordingly. Inconvenient though this may be, it has the advantage -that 'GHC.Core.Utils.exprType' can still return a type for any expression, including -a jump. - -This differs from the paper (see Note [Invariants on join points]). In the -paper, we instead give j the type `Int -> Bool -> forall a. a`. Then each jump -carries the "return type" as a parameter, exactly the way other non-returning -functions like `error` work: +The body of the join point now returns a Bool, so the label `j` has to +have its type updated accordingly, which is done by +GHC.Core.Opt.Simplify.Env.adjustJoinPointType. Inconvenient though +this may be, it has the advantage that 'GHC.Core.Utils.exprType' can +still return a type for any expression, including a jump. + +Relationship to the paper + +This plan differs from the paper (see Note [Invariants on join +points]). In the paper, we instead give j the type `Int -> Bool -> +forall a. a`. Then each jump carries the "return type" as a parameter, +exactly the way other non-returning functions like `error` work: case (join j :: Int -> Bool -> forall a. a |