haskell - How to generate arbitrary two argument function with QuickCheck? -




i trying test implementation of zipwith using quickcheck. implementation, myzipwith, quickcheck test comparing standard function. like:

main =   quickcheck (prop_myzipwith :: (int -> int -> int) -> [int] -> [int] -> bool)  prop_myzipwith :: (a -> b -> c) -> [a] -> [b] -> bool prop_myzipwith f x y = (myzipwith x y) == (zipwith f x y) 

this not work because (int -> int -> int) not instance of arbitrary.

with single-argument functions 1 can around using test.quickcheck.function's fun (which instantiates arbitrary). example:

main =   quickcheck (prop_mymap :: fun int int -> [int] -> bool)  prop_mymap :: fun b -> [a] -> bool prop_mymap (fun _ f) l = (mymap f l) == (map f l) 

i trying similar except generating two-argument arbitrary functions.

how can generate arbitrary instances of 2 argument functions quickcheck testing of higher-order functions such zipwith?





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -