diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-06-03 18:19:52 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-06-03 18:19:52 +0200 |
commit | cc193feee38429e1a853cc23365b95e96b206672 (patch) | |
tree | 2d41604ec85ed6a2c105f71b98150fae2744b609 | |
parent | cbda266091d45e564fc91462856e4f0571d18aca (diff) |
Generalise monad in some test generators
-rw-r--r-- | test/Gen.hs | 8 |
1 files 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 |