[xmonad] How do you test ManageHook using QuickCheck?

Linus Arver linusarver at gmail.com
Wed Feb 15 02:38:42 CET 2012

On Mon, Feb 06, 2012 at 12:14:18PM +0100, Takafumi Arakaki wrote:
> Thank you Linus,
> On Sun, Feb 5, 2012 at 7:00 PM, Linus Arver <linusarver at gmail.com> wrote:
> > You should separate out the pure computations out of your managehook
> > stuff and then use QuickCheck on those functions. A zero-division error
> > sounds like it's from your own code (if not, then you should contact the
> > maintainer(s) of the libraries in question and send a bug report).
> I'd like to see the example of separating "the pure computations out
> of your managehook stuff and then use QuickCheck on those functions".
> But I suppose it is possible to test the manage hook as is (w/o
> separating the pure computation part), or it is not?  And yes, the
> zero-division error is in my management hook.

What I meant was, just test the pure (monad-free) code that you added on
your own in your managemenet hook stuff. I.e., you should refactor your
functions so that the pure parts are separate on their own, and then
test these smaller (pure) functions. Here's a tutorial on how to do
this: http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck. The
"getList" function's type signature there is "IO String", and the
tutorial goes on about how to test the pure, smaller parts outside of
the IO monad.

Testing the manage hook "as is" w/o separating the pure computation part
is probably really hard to do... if I'm not mistaken XMonad already uses
QuickCheck so you'd have to dig inside the XMonad code for some
examples. This is a lot more difficult than just testing pure parts...

You could post your managment hook code on this list or the Haskell
Beginner's list [1] for more specific pointers.

[1] http://www.haskell.org/mailman/listinfo/beginners


More information about the xmonad mailing list