
#9388: Narrow the scope of the notorious "state hack" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): Ah, I think it might have been me, at least partially: In `MkId`, the `realWorldPrimId` has `setOneShotInfo` stateHackOneShot set. This means that _every_ lambda with an argument of type `State#` is marked as oneshot. This was introduced in changeset:80989de/ghc – maybe this bit was not even meant to be merged? Back then, the `OneShotInfo` would not be exported, so the unfolding for `hPutStr2` would say `(\ s ::String eta :: State# RealWorld -> ...` But when I added the `oneShot` magic function, I also made sure that the `OneShotInfo` would be written to the interface, so it now says `(\ s ::String eta :: State# RealWorld[oneShot] -> ...` and the simplifier will float in the call to `reverse`. I’ll rip out all state hack code (which seems to be implemented by `OneShotInfo` on `realWorldPrimId` and via `typeOneShot`) and see if I can achieve something similar in a cleaner way and only for top-level bindings in the cardinality analysis. It’s a nice weekend relaxation from paper proofreading :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9388#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler