
#12620: Allow the user to prevent floating and CSE -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9520, #8457 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by edsko): But perhaps I misunderstood: yes, marking the ''function type'' as "oneshot" `Maybe Char -o Sink` would also do the trick. Although I'm not a fan of calling this "oneshot", or indeed the `-o` notation (borrowed from linearity). The whole point is that these functions _might_ be executed more than once; after all, if we were guaranteed that that wouldn't happen, we wouldn't be hanging on to them and there would be no memory leak. But marking that function as "noupdate" or whatever would seem to make sense; of course, now we can ask the same question as you asked above: what about {{{#!hs foo :: Maybe Char -> Sink {-# NOUPDATE foo #-} foo = if <expensive> then f1 else f2 }}} but I guess this is far less likely to be a problem in practice; how often do we write something like {{{#!hs await >>= if <expensive> then f1 else f2 }}} I think almost never; this is far more likely {{{#!hs await >>= \mi -> if <expensive> then c1 else c2 }}} and that would be just fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12620#comment:28 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler