[Haskell-cafe] Random pattern generation with list comprehensions
mgsloan at gmail.com
Sat Dec 13 03:16:10 UTC 2014
It sounds like you're looking for the ParallelListComp language extension
Another option might be to leverage the Arbitrary typeclass in
QuickCheck. It has instances for tuples, so if each component of
the tuple has an Arbitrary instance, you can generate the whole tuple
with one invocation of "arbitrary". The CoArbitrary typeclass is also
rather handy and clever, as it allows you to create random functions,
as long as the arguments are instances of CoArbitrary and the result
is an instance of Arbitrary. Your concept of specifying run length is
very similar to QuickCheck's "size parameter".
I hope that's helpful!
More information about the Haskell-Cafe