
#1904: Strictness analyser should be smarter -------------------------------+-------------------------------------------- Reporter: igloo | Owner: Type: bug | Status: closed Priority: normal | Milestone: _|_ Component: Compiler | Version: 6.8.1 Resolution: fixed | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed Comment: The code now looks good. Here is Case A, with `-ddump-simpl -O` output: {{{ foo :: String -> [String] -> Bool foo x _ | x `seq` x == "." = True foo x xs = x `seq` any (x ==) xs ===== T1904.foo = \ (x_aeG :: GHC.Base.String) (ds_dl8 :: [GHC.Base.String]) -> case x_aeG of x1_XeK { __DEFAULT -> case GHC.Base.eqString x1_XeK T1904.foo1 of _ { GHC.Types.False -> GHC.List.any @ GHC.Base.String (GHC.Base.eqString x1_XeK) ds_dl8; GHC.Types.True -> GHC.Types.True } } }}} Now without the first `seq`, Case B: {{{ foo :: String -> [String] -> Bool foo x _ | x == "." = True foo x xs = x `seq` any (x ==) xs ==== T1904.foo = \ (x_aeG :: GHC.Base.String) (ds_dl7 :: [GHC.Base.String]) -> case GHC.Base.eqString x_aeG T1904.foo1 of _ { GHC.Types.False -> case x_aeG of x1_akh { __DEFAULT -> GHC.List.any @ GHC.Base.String (GHC.Base.eqString x1_akh) ds_dl7 }; GHC.Types.True -> GHC.Types.True } }}} Notice that both have one remaining `seq` on `x`, but in one case it's before the call to `eqString`, and in the other case after it, which is as it should be. So I'm happy here, and am closing. Re-open if you disagree. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1904#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler