diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-11-07 17:24:47 -0500 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2019-11-17 07:21:44 -0500 |
commit | 44a1a9e9502025390ccd64555d87c8d7186bc4a1 (patch) | |
tree | a7f87931f244ef2f9011597f7bca7fb16dfa4310 /compiler/simplCore/Simplify.hs | |
parent | f8971129cb50a0c2f01a09b6fe46f8e92d2a6e88 (diff) | |
download | haskell-wip/T17440.tar.gz |
Give seq a more precise type and remove magicwip/T17440
`GHC.Prim.seq` previously had the rather plain type:
seq :: forall a b. a -> b -> b
However, it also had a special typing rule to applications
where `b` is not of kind `Type`.
Issue #17440 noted that levity polymorphism allows us to rather give
it the more precise type:
seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b
This allows us to remove the special typing rule that we previously
required to allow applications on unlifted arguments. T9404 contains a
non-Type application of `seq` which should verify that this works as
expected.
Closes #17440.
Diffstat (limited to 'compiler/simplCore/Simplify.hs')
-rw-r--r-- | compiler/simplCore/Simplify.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs index 795b0f5654..569bcfd3dc 100644 --- a/compiler/simplCore/Simplify.hs +++ b/compiler/simplCore/Simplify.hs @@ -2090,11 +2090,16 @@ trySeqRules in_env scrut rhs cont no_cast_scrut = drop_casts scrut scrut_ty = exprType no_cast_scrut seq_id_ty = idType seqId + res1_ty = piResultTy seq_id_ty rhs_rep + res2_ty = piResultTy res1_ty scrut_ty rhs_ty = substTy in_env (exprType rhs) - out_args = [ TyArg { as_arg_ty = scrut_ty + rhs_rep = getRuntimeRep rhs_ty + out_args = [ TyArg { as_arg_ty = rhs_rep , as_hole_ty = seq_id_ty } + , TyArg { as_arg_ty = scrut_ty + , as_hole_ty = res1_ty } , TyArg { as_arg_ty = rhs_ty - , as_hole_ty = piResultTy seq_id_ty scrut_ty } + , as_hole_ty = res2_ty } , ValArg no_cast_scrut] rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs , sc_env = in_env, sc_cont = cont } |