[Haskell-cafe] QuickCheck2 question

Patrick Perry patperry at gmail.com
Mon Oct 12 22:32:47 EDT 2009


I'm having some trouble with QuickCheck2 and Control.Applicative.  Specifically, I have the following functions (slightly simplified):

    copyVector :: IOVector -> Vector -> IO ()
    freezeVector :: IOVector -> IO (Vector)

I have a test, part of which looks like

    monadicIO $ do
        run $ copyVector <$> pure dst <*> freezeVector src
        -- more stuff...

When I try running the test (using test-framework-quickcheck2), the `copyVector` function never gets called.

If I re-write the test as

    monadicIO $ do
        src' <- run $ freezeVector
        run $ copyVector dst src'
        -- etc.

then everything works fine (i.e., the call to `copyVector` gets executed).  

Does anyone have any clues as to what is going on?  I suspect the problem is related to Test.QuickCheck.Monadic using `unsafePerformIO` without a `{-# NOINLINE -#}` pragma [1], but I'm not completely sure.  Adding such a pragma to `monadicIO` and `run` in Monadic.hs does not fix the problem.

I'm using Quickcheck-2.1.0.2 and GHC 6.10.1.  

Thanks in advance for any help,


Patrick

[1] http://hackage.haskell.org/packages/archive/QuickCheck/2.1.0.2/doc/html/src/Test-QuickCheck-Monadic.html


More information about the Haskell-Cafe mailing list