From cc193feee38429e1a853cc23365b95e96b206672 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 3 Jun 2024 18:19:52 +0200 Subject: Generalise monad in some test generators --- test/Gen.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Gen.hs b/test/Gen.hs index bcd7a4e..bd641af 100644 --- a/test/Gen.hs +++ b/test/Gen.hs @@ -33,7 +33,7 @@ import System.Random qualified as Random import Util -genRank :: (forall n. SNat n -> PropertyT IO ()) -> PropertyT IO () +genRank :: Monad m => (forall n. SNat n -> PropertyT m ()) -> PropertyT m () genRank k = do rank <- forAll $ Gen.int (Range.linear 0 8) TN.withSomeSNat (fromIntegral rank) k @@ -87,17 +87,17 @@ genStorables rng f = do let readW64 i = sum (zipWith (*) (iterate (*256) 1) [fromIntegral (bs `BS.index` (8 * i + j)) | j <- [0..7]]) return $ VS.generate n (f . readW64) -genStaticShX :: (forall sh. StaticShX sh -> PropertyT IO ()) -> PropertyT IO () +genStaticShX :: Monad m => (forall sh. StaticShX sh -> PropertyT m ()) -> PropertyT m () genStaticShX = \k -> genRank (\sn -> go sn k) where - go :: SNat n -> (forall sh. StaticShX sh -> PropertyT IO ()) -> PropertyT IO () + go :: Monad m => SNat n -> (forall sh. StaticShX sh -> PropertyT m ()) -> PropertyT m () go SZ k = k ZKX go (SS n) k = genItem $ \item -> go n $ \ssh -> k (item :!% ssh) - genItem :: (forall n. SMayNat () SNat n -> PropertyT IO ()) -> PropertyT IO () + genItem :: Monad m => (forall n. SMayNat () SNat n -> PropertyT m ()) -> PropertyT m () genItem k = do b <- forAll Gen.bool if b -- cgit v1.2.3-70-g09d2