Although ghc-vis is meant to be used in GHCi it can also be used as a library in regular Haskell programs which are run or compiled by GHC. You can run those programs using "runghc example.hs" or "ghc -threaded example.hs && ./example". Without the "-threaded"-Flag ghc-vis does not work correctly. This is an example using ghc-vis outside of GHCi:
import GHC.Vis main = do putStrLn "Start" let a = "teeest" let b = [1..3] let c = b ++ b let d = [1..] putStrLn $ show $ d !! 1 visualization view a "a" view b "b" view c "c" view d "d" getChar switch getChar putStrLn "End"
This is the main function. It's to be called from GHCi and launches a graphical window in a new thread.
A minimalistic version of ghc-vis, without window decorations, help and all that other stuff.
Evaluate an object that is shown in the visualization. (Names start with
When an object is updated by accessing it, you have to call this to refresh the visualization window. You can also click on an object to force an update.