[Haskell-beginners] QuickCheck with monadic IO

Daniel Seidel ds at iai.uni-bonn.de
Sat Aug 13 19:59:12 CEST 2011


Hi Hartmut,

if I just copy,paste and compile your example it takes less than 0.01s
to run the tests. So, probably the problem is not in the code.
BTW, I use GHC 7.0.1.

Cheers,

Daniel.

On Fri, 2011-08-12 at 23:31 +0200, Hartmut wrote:
> Everyone,
> 
> I want to run an QuickCheck on "a most simple" IO monad.
> When I compile and run :main, it says:
> ....................................................................................................+++ OK, passed 100 tests.
> Well, thats fine, since *1 mapped on any Int gives the same Int back.
> But it lasts 10 seconds (!) for doing those 100 Tests.
> Something must be wrong?!
> I'd appreciate your ideas.
> 
> Hartmut
> 
> 
> module MonadicQuickCheck where
> 
> import IO
> import Random
> import Test.QuickCheck
> import Test.QuickCheck.Monadic
> 
> main = do
>   quickCheck x
>   
> x :: Property
> x = monadicIO $ do 
>   a <- pick arbitrary
>   pre $ not(null a)
>   b <- run $ testfunction a
>   assert $ b == a
> 
> testfunction :: [Int] -> IO [Int]
> testfunction x = do
>   putStr "."
>   return $ map (*1) x
> 
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list