
This patch contains a module GenT for QuickCheck 2. GenT is a monad transformer variant of the Gen monad. GenT can be used to test monadic actions with QuickCheck or to create random values in monads for benchmarking etc. The module includes two functions to convert GenT actions to and from Gen. The following is an example that tests some functions in the STM monad: prop_InsertLookup :: Gen (STM Bool) prop_InsertLookup = toGen $ do ht <- lift (new :: STM (HashTable Int String)) key <- fromGen (arbitrary :: Gen Int) value <- fromGen (arbitrary :: Gen String) lift $ insert ht key value result <- lift $ lookup ht key return (result == Just value) Run the test with: quickCheck $ fmap (unsafePerformIO . atomically) prop_InsertLookup Regards, Felix