# Changes between Initial Version and Version 1 of Ticket #7411, comment 31

Ignore:
Timestamp:
May 14, 2018 1:52:58 PM (16 months ago)
Comment:

### Legend:

Unmodified
 initial For the second one, let me summarize what I think the core of the problem is: The equational reasoning strategies behind this eta expansion and seq are at odds. The eta expansion assumes that floating bottoms around will not make an effective difference (as per fast-and-loose reasoning), but this assumption doesn't hold when seq is involved, because seq is like this magical backdoor to bottoms. Eta expansion says that case x of { _ -> f } is equivalent to \eta -> case x of { _ -> f eta }, even if there are bottoms involved. But this breaks when seq is involved, because the eta expansion allows the argument to slip past seq. So what we would need to fix this "properly" would be a way to mark the relevant code sections as "here be dragons", and make the state hack skip over those. But I suspect this would be a rather invasive change (extending Core with such markers), and detecting such sections correctly could be tricky. Or maybe not, I really don't know. So what we would need to fix this "properly" would be a way to mark the relevant code sections as "here be dragons", and make the state hack skip over those. E.g., in the example program discussed earlier: {{{ import Control.Exception dslist :: [a] -> b -> b dslist [] b = b dslist (x:xs) b = x seq dslist xs b main = evaluate (('a':undefined) dslist return () :: IO ()) }}} ...we would mark the {{{x seq dslist xs b}}} part as "dangerous", and forbid eta-expanding across this boundary. Or rather, in this bit here: {{{ lvl_s2Yn [Occ=Once]   -- Comes from 'return ()' :: GHC.Prim.State# GHC.Prim.RealWorld -> (# GHC.Prim.State# GHC.Prim.RealWorld, () #) [LclId] lvl_s2Yn = \ (s_a2z6 [Occ=Once, Dmd=] :: GHC.Prim.State# GHC.Prim.RealWorld) -> (# s_a2z6, GHC.Tuple.() #) lvl_s2Yo [Occ=Once] :: GHC.Types.IO () [LclId]  -- Comes from (('a':undefined) dslist return ()) lvl_s2Yo = case go_s2WQ lvl_s2Ym of { __DEFAULT -> lvl_s2Yn cast (Sym (GHC.Types.N:IO[0] <()>_R) :: (GHC.Prim.State# GHC.Prim.RealWorld -> (# GHC.Prim.State# GHC.Prim.RealWorld, () #) :: *) ~R# (GHC.Types.IO () :: *)) } main_s2z7 = \ (s_a2yI [Occ=Once, Dmd=] :: GHC.Prim.State# GHC.Prim.RealWorld) -> GHC.Prim.seq# @ (GHC.Types.IO ()) @ GHC.Prim.RealWorld lvl_s2Yo s_a2yI }}} ...we would have to drag along the information that go_s2WQ is dangerous, and infer from that that we cannot eta-expand lvl_s2Yo. But I suspect this would be a rather invasive change (extending Core with such markers), and detecting such sections correctly could be tricky. Or maybe not, I really don't know.