Looking for some way to generate large vectors efficiently
hedgehog seems to be slow generating large vectors in CI environment. This is perhaps because the CI environment is underpowered compared to my development environment, but the problem of generating a Vector Word64 up to size 16384 100 times doesn't sound like it ought to be too expensive an operation.
The vector generator is:
storableVector :: (MonadGen m, DVS.Storable a) => Range Int -> m a -> m (DVS.Vector a)
storableVector r g = DVS.fromList <$> G.list r g
Here is an example of the above scenario taking 41s:
https://circleci.com/gh/haskell-works/hw-balancedparens/1233
The following hacky implementation is proving to be a lot faster:
storableVectorWord64 :: MonadGen m => Range Int -> m (DVS.Vector Word64)
storableVectorWord64 r = fromGenT $ do
n <- integral_ r
GenT $ \_ seed ->
return $ flip (DVS.unfoldrN n) seed $ \s ->
let (w, sb) = nextWord64 s in Just (w, sb)
It would be nice to have a vector support in hedgehog that can generate vectors fast and can accept an arbitrary generator.
Would there be interest in something like this?
Also would anyone be able to offer some help?
I have confusion around to properly negotiate the monad stack and I haven't been able find examples in the code to make a working example.