Xmonad/ghci: Difference between revisions
(start the page) |
m (paragraphs) |
||
Line 9: | Line 9: | ||
We can then load up everything into ghci with: | We can then load up everything into ghci with: | ||
<code> | <code> | ||
ghci -iXMonadContrib -iiorefState/src -ilib xmonad.hs | ghci -iXMonadContrib -iiorefState/src -ilib xmonad.hs | ||
Line 14: | Line 15: | ||
Then start your usual main as a separate thread, so that the repl can still work: | Then start your usual main as a separate thread, so that the repl can still work: | ||
<code> | <code> | ||
import Control.Concurrent | import Control.Concurrent | ||
Line 22: | Line 24: | ||
Then we can do things like | Then we can do things like | ||
<code> | <code> | ||
readIORef xstateRef | readIORef xstateRef | ||
killThread xm -- does not release resources properly, so a second call to main will fail | killThread xm -- does not release resources properly, so a second call to main will fail | ||
</code> | </code> |
Latest revision as of 20:37, 8 February 2015
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