[Haskell-cafe] Re: Generating repeatable arbitrary values with
QuickCheck 2
Ryan Ingram
ryani.spam at gmail.com
Tue Feb 2 17:09:18 EST 2010
Although now that I think about it, most of these could be pretty
easily fixed by a new primitive:
> splitGen :: Gen a -> Gen a
> splitGen m = MkGen spg where
> spg g n = (a, g2) where
> (g1, g2) = split g
> (a, _) = unGen m g1 n
Then you could do
> infinite_xs <- splitGen $ sequence (repeat arbitrary)
-- ryan
On Tue, Feb 2, 2010 at 2:04 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> On Tue, Feb 2, 2010 at 11:25 AM, David Menendez <dave at zednenem.com> wrote:
>> We could avoid that problem by redefining Gen as a state transformer monad.
>>
>> newtype Gen a = MkGen { unGen :: StdGen -> Int -> (a, StdGen) }
>
> Unfortunately, this makes things like
>> infinite_xs <- sequence (repeat arbitrary)
> no longer work, since the state never comes out the other side.
>
> Which is a pretty significant change.
>
> -- ryan
>
More information about the Haskell-Cafe
mailing list