{-# LANGUAGE Rank2Types #-}
module Test.Tasty.QuickCheck.Laws.MaybeMonad (
testMaybeMonadLaws
, testMaybeMonadLawBailThen
) where
import Data.Proxy
( Proxy(..) )
import Data.Typeable
( Typeable, typeRep )
import Test.Tasty
( TestTree, testGroup )
import Test.Tasty.QuickCheck
( testProperty, Property, Arbitrary(..) )
import Text.Show.Functions
()
import Test.Tasty.QuickCheck.Laws.Class
testMaybeMonadLaws
:: ( Monad m
, Eq a
, Show t, Show a
, Show (m a)
, Arbitrary t, Arbitrary a
, Arbitrary (m a)
, Typeable m, Typeable a
)
=> Proxy m
-> Proxy t
-> Proxy a
-> (forall u. (Eq u) => t -> m u -> m u -> Bool)
-> (forall a. m a)
-> TestTree
testMaybeMonadLaws pm pt pa eq bail =
let
label = "Maybe Monad Laws for " ++ (show $ typeRep pm) ++ " with " ++
"a :: " ++ (show $ typeRep pa)
in
testGroup label
[ testMaybeMonadLawBailThen pm pt pa eq bail
]
testMaybeMonadLawBailThen
:: ( Monad m, Eq a
, Show t
, Arbitrary t, Arbitrary (m a), Show (m a)
)
=> Proxy m
-> Proxy t
-> Proxy a
-> (forall u. (Eq u) => t -> m u -> m u -> Bool)
-> (forall a. m a)
-> TestTree
testMaybeMonadLawBailThen pm pt pa eq bail =
testProperty "bail >> x === x" $
maybeMonadLawBailThen pm pt pa eq bail
maybeMonadLawBailThen
:: (Monad m, Eq a)
=> Proxy m -> Proxy t -> Proxy a
-> (forall u. (Eq u) => t -> m u -> m u -> Bool)
-> (forall a. m a)
-> t -> m a -> Bool
maybeMonadLawBailThen _ _ _ eq bail t x =
(eq t) (bail >> x) (bail)