[Haskell-cafe] SmallCheck design question
ndmitchell at gmail.com
Tue Dec 8 11:38:40 EST 2009
I'm cc'ing the people behind smallcheck, who can give definitive answers.
> 1. why are the tuple constructors treated differently?
> I'd expect depth (x,y) = succ $ max (depth x) (depth y)
> but the succ is missing.
I think this was a design choice. Some people would consider:
data Foo = Foo a b
data Foo = Foo (a,b)
to be roughly the same - in some way the tuple is just to group
things up, but it never is any structure by itself, since any
structure it has is limited by the type system. But it could have been
defined the other way.
> 2. why depth and not size (= total number of constructors)?
> it seems that the number of objects (trees) of given depth
> rises much more drastically than number of trees of given size.
That seems harder to generate terms compositionally. To create all
terms of depth n+1 you just glue together all terms of depth n, but to
create terms of size n+1 you need to glue 1 with n, 2 with n-1 etc.
More information about the Haskell-Cafe