Gmane
Picon
From: Felix Martini <fmartini <at> gmail.com>
Subject: darcs patch: GenT monad transformer variant of Gen (QuickCheck 2)
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-08-12 13:06:21 GMT (39 weeks, 4 days, 14 hours and 33 minutes ago)
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
Attachment (patchset): application/octet-stream, 4541 bytes
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries