Allows testing of monadic values. Will generally follow this form:
prop_monadic a b = 'monadicIO' $ do
a\' \<- 'run' (f a)
b\' \<- 'run' (f b)
-- ...
'assert' someBoolean
Example using the FACTOR(1) command-line utility:
import System.Process
import Test.QuickCheck
import Test.QuickCheck.Monadic
-- $ factor 16
-- 16: 2 2 2 2
factor :: Integer -> IO [Integer]
factor n = parse \`fmap\` 'System.Process.readProcess' \"factor\" [show n] \"\" where
parse :: String -> [Integer]
parse = map read . tail . words
prop_factor :: Positive Integer -> Property
prop_factor ('Test.QuickCheck.Modifiers.Positive' n) = 'monadicIO' $ do
factors \<- 'run' (factor n)
'assert' (product factors == n)
See the paper "Testing Monadic Code with QuickCheck".