
#11555: catch _|_ breaks at -O1 -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): We could provide both `catch`-made-strict and `safeCatch`, and maybe discuss which should be the "default" in the sense of using the existing name `catch`. Though it's not just `catch`, there's `try` and other related functions as well. Maybe better to add a new `execute a = join (evaluate a)`. Simon, you wrote elsewhere (ticket:10712#comment:22):
`catch` is ''not'' strict in its argument. Its argument is a function; `catch` just guarantees to call that function.
But I don't understand. Really `catch` has two arguments `catch act handler` and we're talking about strictness in `act`. Isn't `catch` strict in `act` (once applied to `handler`)? If `act` itself is _|_ then we are saying (in #10712) then `catch act handler` is allowed to be _|_. The funny property of `catch` comes in the fact that even though `catch` is going to ''apply'' `act`, it is not strict in that application because of its magical turning-bottom-into-non-bottom property. So, doesn't `catch` just have the same strictness in `act` as does, say, `seq` at a function type? Similarly I don't understand this excerpt from Note [Exceptions and strictness]:
This also applies uniformly to free variables. Consider {{{ let r = \st -> raiseIO# blah st in catch# (\s -> ...(r s')..) handler st }}} If we give the first argument of catch a strict signature, we'll get a demand 'C(S)' for 'r'; that is, 'r' is definitely called with one argument, which indeed it is.
Why can't we give `catch#` a signature that says it is strict in its argument, without necessarily ''calling'' that argument? Just like `seq`. I see that 9915b6564403a6d17651e9969e9ea5d7d7e78e7f is quite a large commit, so likely I'm missing the whole picture. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11555#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler