[GHC] #11601: Strict Haskell is not as strict as it probably should be

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider this with `-XStrict` {{{ f y = let Just x = blah[y] in body[y,x] }}} Suppose that in a call to `f`, * `blah` returns `Nothing` * but `body` does not use `x` Should `f` succeed? For sure, `blah` will be evaluated to HNF before `body` is started, but is the match against `Just` done strictly too? According to [http://downloads.haskell.org/~ghc/master/users- guide/glasgow_exts.html#recursive-and-polymorphic-let-bindings our current semantics], in the match against `Just` is ''not'' done strictly, so the call should succeed. I think that’s unexpected and probably wrong. The translation goes like this: {{{ !(Just x) = blah ==> (FORCE) v = blah; Just x = v (and add a seq on v) ==> (SPLIT) v = blah; x = case v of Just x -> x }}} So we finish up with {{{ f y = let v = blah[y] in let x = case v of Just x -> x in v `seq` body[y,x] }}} I don’t think that’s what we intended, because there's a thunk for `x`. If the pattern can fail, I think we want the FORCE rule to say this: {{{ Replace any binding !p = e with v = case e of p -> (v1,..,vn); (v1,..,vn) = v and replace e0 with v seq e0, where v is fresh and v1..vn are the variable(s) bound by p }}} (Compare with the text at the above link.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => merge * milestone: => 8.0.1 Comment: Seems like this is something we should fix for 8.0. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Merged in d6ea90a213fb32ea0af666dec25697228cc09a26. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: tibbe (added) Comment: It's #11572 that is fixed. This ticket is very much open. I need feedback about the desired behaviour. (Johan?) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tibbe): I think the pattern match should be done strictly as well. I'd expect that's what happens in e.g. Scala or Rust. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deSugar/should_run/T11601 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => deSugar/should_run/T11601 Comment: Yay. This is much better. Merge to 8.0 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11601: Strict Haskell is not as strict as it probably should be -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deSugar/should_run/T11601 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11601#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC