
#16089: seq is not cooperating with :sprint in GHCi as expected -------------------------------------+------------------------------------- Reporter: radrow | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.3 Resolution: | Keywords: seq sprint | strictness Operating System: Linux | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #7253 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): I did a little bit of digging. The only difference between `:sprint` and `:print` is that `:sprint` doesn't bind "suspensions". So sometimes you see a `_` with `:sprint`, but `:print` gives you a variable instead (see last two code snippets in comment:1). What is a "suspension"? `RtClosureInspect` has a simplistic view of Haskell runtime objects, and it treats these as "suspensions": - `BLACKHOLE`s that point to `TSO` or `BLOCKING_QUEUE`s (as expected, becuase these are thunks that are not evaluated yet) - Anything other than `MUT_VAR` and `CONSTR`s. When we do `:print x` what `RtClosureInspect` uses `ghc-heap` to inspect the value of `x` and sees an `AP` that looks like this: {{{ APClosure { info = StgInfoTable { entry = Nothing , ptrs = 0 , nptrs = 0 , tipe = AP , srtlen = 0 , code = Nothing } , arity = 709704 , n_args = 0 , fun = () <-- this is actually a `ForeignRef HValue`, but shown as () because we cna't show `ForeignRef`s , payload = [] } }}} which is probably a bug in `ghc-heap` because even if `x` is really an `AP` the `arity` field makes no sense (it should be 0). For reference, the BCOs generated for `x = [True,False]`: {{{ ProtoBCO x1_r1zt#0 []: GHC.Types.: @ GHC.Types.Bool GHC.Types.False (GHC.Types.[] @ GHC.Types.Bool) bitmap: 0 [] PUSH_G GHC.Types.[] PUSH_G GHC.Types.False PACK : 2 ENTER ProtoBCO Ghci1.x#0 []: GHC.Types.: @ GHC.Types.Bool GHC.Types.True x1_r1zt bitmap: 0 [] PUSH_G x1_r1zt PUSH_G GHC.Types.True PACK : 2 ENTER }}} BCO generated for `let x = [True,False]`: {{{ ProtoBCO ExprTopLevel_E0#0 []: let sat_s1yG = ... in ... bitmap: 0 [] PUSH_G GHC.Types.[] PUSH_G GHC.Types.False PACK : 2 PUSH_L 0 PUSH_G GHC.Types.True PACK : 2 PUSH_G GHC.Types.[] PUSH_L 1 PACK : 2 PUSH_L 0 PUSH_APPLY_P PUSH_G GHC.Base.returnIO SLIDE 3 3 ENTER }}} These should really be identical. For this I filed #16096. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16089#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler