summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-12-10 17:32:34 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2018-12-21 13:00:14 +0000
commit28188e06b4953f589c7cd442ae14787bc74cabf8 (patch)
tree666bd2b0763dbd1c65f66fa23a3599e76628edca /compiler
parent71e26a74da5e5e9a61163b87ab4d22de88a2d04a (diff)
downloadhaskell-28188e06b4953f589c7cd442ae14787bc74cabf8.tar.gz
Comments only
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rename/RnSource.hs6
-rw-r--r--compiler/simplCore/SetLevels.hs22
2 files changed, 17 insertions, 11 deletions
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 78444ba126..c76eb31abc 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -698,7 +698,7 @@ rnFamInstEqn :: HsDocContext
-> Maybe (Name, [Name]) -- Nothing => not associated
-- Just (cls,tvs) => associated,
-- and gives class and tyvars of the
- -- parent instance delc
+ -- parent instance decl
-> [Located RdrName] -- Kind variables from the equation's RHS
-> FamInstEqn GhcPs rhs
-> (HsDocContext -> rhs -> RnM (rhs', FreeVars))
@@ -801,7 +801,9 @@ rnFamInstEqn doc mb_cls rhs_kvars
rnFamInstEqn _ _ _ (HsIB _ (XFamEqn _)) _ = panic "rnFamInstEqn"
rnFamInstEqn _ _ _ (XHsImplicitBndrs _) _ = panic "rnFamInstEqn"
-rnTyFamInstDecl :: Maybe (Name, [Name])
+rnTyFamInstDecl :: Maybe (Name, [Name]) -- Just (cls,tvs) => associated,
+ -- and gives class and tyvars of
+ -- the parent instance decl
-> TyFamInstDecl GhcPs
-> RnM (TyFamInstDecl GhcRn, FreeVars)
rnTyFamInstDecl mb_cls (TyFamInstDecl { tfid_eqn = eqn })
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index e685b3a65a..2f993b7148 100644
--- a/compiler/simplCore/SetLevels.hs
+++ b/compiler/simplCore/SetLevels.hs
@@ -462,7 +462,7 @@ lvlCase :: LevelEnv -- Level of in-scope names/tyvars
lvlCase env scrut_fvs scrut' case_bndr ty alts
-- See Note [Floating single-alternative cases]
| [(con@(DataAlt {}), bs, body)] <- alts
- , exprIsHNF (deTagExpr scrut') -- See Note [Check the output scrutinee for okForSpec]
+ , exprIsHNF (deTagExpr scrut') -- See Note [Check the output scrutinee for exprIsHNF]
, not (isTopLvl dest_lvl) -- Can't have top-level cases
, not (floatTopLvlOnly env) -- Can float anywhere
= -- Always float the case if possible
@@ -535,21 +535,25 @@ Things to note:
* We only do this with a single-alternative case
-Note [Check the output scrutinee for okForSpec]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note [Check the output scrutinee for exprIsHNF]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
case x of y {
A -> ....(case y of alts)....
}
+
Because of the binder-swap, the inner case will get substituted to
-(case x of ..). So when testing whether the scrutinee is
-okForSpeculation we must be careful to test the *result* scrutinee ('x'
-in this case), not the *input* one 'y'. The latter *is* ok for
-speculation here, but the former is not -- and indeed we can't float
-the inner case out, at least not unless x is also evaluated at its
-binding site. See Trac #5453.
+(case x of ..). So when testing whether the scrutinee is in HNF we
+must be careful to test the *result* scrutinee ('x' in this case), not
+the *input* one 'y'. The latter *is* in HNF here (because y is
+evaluated), but the former is not -- and indeed we can't float the
+inner case out, at least not unless x is also evaluated at its binding
+site. See Trac #5453.
That's why we apply exprIsHNF to scrut' and not to scrut.
+
+See Note [Floating single-alternative cases] for why
+we use exprIsHNF in the first place.
-}
lvlNonTailMFE :: LevelEnv -- Level of in-scope names/tyvars