[Haskell-cafe] Generating random arguments for a function

satvik chauhan mystic.satvik at gmail.com
Sat Jan 12 20:33:08 CET 2013


I am trying to use quickcheck to generate random arguments of a given
function (assuming all its types have Arbitrary instance and Show instance)
along with the evaluation of the function at those arguments.

Suppose I have a function

    add :: Int -> Int -> Int
    add a b = a+b

Then I assume a behavior like

    > randomEvaluate add
    (["1","3"],"4")

where 1 and 3 are random values generated for `Int` and 4 is `f 1 3`.

I have asked this on
SO<http://stackoverflow.com/questions/14294802/evaluating-function-at-random-arguments-using-quickcheck>
but
am not fully satisfied with the answers.

-Satvik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130113/8732dcd0/attachment.htm>


More information about the Haskell-Cafe mailing list