Repro Main.hs:
module Main where
import GHC.Debugger.View.Class
data X = X String
deriving Show
instance DebugView X where
debugValue _ = simpleValue "T300-X" True
debugFields (X s) = pure $ VarFields
[ ("thunkInt", VarFieldValue intThunk)
]
where
intThunk :: Int
intThunk = sum [1 .. length s + 99]
main :: IO ()
main = f (X "A")
f :: Show a => a -> IO ()
f action = do
print action
T300.cabal:
cabal-version: 3.14
name: T300
version: 0.1.0.0
license: NONE
author: Rodrigo Mesquita
maintainer: rodrigo.m.mesquita@gmail.com
build-type: Simple
common warnings
ghc-options: -Wall
executable t300
import: warnings
main-is: Main.hs
build-depends: base, containers
build-depends: haskell-debugger-view
hs-source-dirs: .
default-language: Haskell2010
The problem happens if you break on print action, look at action in the variables pane (which uses DebugView), force the thunkInt field of the action, and observe that it displays the right value momentarily, but immediately is cleared to a thunk again.
The "clear" is caused by the invalidate request which is sent whenever a value is forced, triggering a re-draw of the variables.
But re-requesting the variable of the DebugView field should now display the thunk, because the variable has already been evaluated.
I'm going to push a test.
Repro
Main.hs:T300.cabal:The problem happens if you break on
print action, look atactionin the variables pane (which usesDebugView), force thethunkIntfield of theaction, and observe that it displays the right value momentarily, but immediately is cleared to a thunk again.The "clear" is caused by the invalidate request which is sent whenever a value is forced, triggering a re-draw of the variables.
But re-requesting the variable of the
DebugViewfield should now display the thunk, because the variable has already been evaluated.I'm going to push a test.