From HaskellWiki
Jump to navigation Jump to search

XMonad can run in ghci. This allows using the ghci debugger, which allows stepping through execution and inspecting values / exceptions that can occur. Inspecting or modifying IORefs used in xmonad from ghci's main thread is another option, which requires xmonad's code to be modified slightly:

If we have a copy of core patched to put the XState into xstateRef :: IORef XState and contrib unpacked into ~/.xmonad,

darcs get http://code.haskell.org/XMonadContrib darcs get http://code.haskell.org/~aavogt/xmonad/iorefState

We can then load up everything into ghci with:

ghci -iXMonadContrib -iiorefState/src -ilib xmonad.hs

Then start your usual main as a separate thread, so that the repl can still work:

import Control.Concurrent import Data.IORef import System.Environment xm <- forkIO (withArgs ["--replace"] main)

Then we can do things like

readIORef xstateRef killThread xm -- does not release resources properly, so a second call to main will fail