I am trying to write monadic test code using Test.QuickCheck.Monadic
.
The module provides a harness
monadicST :: Testable a => (forall s. PropertyM (ST s) a) -> Property
to execute ST
-based tests, and a function
run :: Monad m => m a -> PropertyM m a
to lift any action into a test monad.
In my code I have a polymorphic monadic action:
act :: Monad m => a -> m ()
act = undefined
The following function
st :: a -> Property
st = monadicST . run . act
fails to compile:
• Couldn't match type ‘PropertyM m0 ()’
with ‘forall s. PropertyM (ST s) a0’
Expected type: PropertyM m0 () -> Property
Actual type: (forall s. PropertyM (ST s) a0) -> Property
• In the first argument of ‘(.)’, namely ‘monadicST’
In the expression: monadicST . run . act
In an equation for ‘st’: st = monadicST . run . act
but this one
st' :: a -> Property
st' a = monadicST $ run $ act a
compiles without a problem.
Can anyone explain?