[Haskell-cafe] Generating arbitrary function in QuickCheck

Jason Dagit dagit at codersbase.com
Tue Apr 7 01:16:51 EDT 2009

On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov <ekirpichov at gmail.com> wrote:
> Since the argument to sortBy must impose a linear ordering on its
> arguments, and any linear ordering may as well be generated by
> assigning an integer to each element of type 'a', and your sorting
> function is polymorphic, from the free theorem for the sorting
> function we may deduce that it suffices to test your function on
> integer lists with a casual comparison function (Data.Ord.compare),
> and there is no need to generate a random comparison function.

Interesting.  How is this free theorem stated for the sorting
function?  Intuitively I understand that if the type is polymorphic,
then it seems reasonable to just pick one type and go with it.


More information about the Haskell-Cafe mailing list