Re: [Haskell-cafe] How to choose an arbitrary Arbitrary?

2008-12-18 Thread Bas van Dijk
On Wed, Dec 17, 2008 at 11:05 PM, Ryan Ingram ryani.s...@gmail.com wrote: ...It's possible to extend this idea and generate an arbitrary arbitrary... Thanks for your thorough answer. I like the SomeArbitrary idea. I see it's easy to also sample[1] SomeArbitrary. You do need to add a 'Show'

[Haskell-cafe] How to choose an arbitrary Arbitrary?

2008-12-17 Thread Bas van Dijk
Hello, I was playing with the following tree type (attached below) which can be seen as the reification of an applicative. I wondered if I could define a QuickCheck Arbitrary instance for it. The only way I got it to type check however, was to give 'arg' a monomorphic type (for example: 'Gen

Re: [Haskell-cafe] How to choose an arbitrary Arbitrary?

2008-12-17 Thread Ryan Ingram
It's absolutely possible. However, I think you do need to enumerate the possible types somehow. Here's an example that demonstrates the idea: {-# LANGUAGE ScopedTypeVariables #-} sizedTree :: forall a. Arbitrary a = Int - Gen (Tree a) sizedTree n | n = 0 = liftM Val arbitrary sizedTree n =