Make Test.QuickCheck.Batch use a default type for testing list functions

Question!

I am testing a function called extractions that operates over any list.

extractions :: [a] -> [(a,[a])]
extractions [] = []
extractions l = extract l []
    where extract [] _ = []
          extract (x:xs) prev = (x, prev++xs) : extract xs (x : prev)

I want to test it, for example, with

import Test.QuickCheck.Batch    
prop_len l = length l == length (extractions l)
main = runTests "extractions" defOpt [run prop_len]

But this won't compile; I have to supply a type either for run or prop_len, because QuickCheck can't generate [a], it has to generate something concrete. So I chose Int:

main = runTests "extractions" defOpt [r prop_len]
    where r = run :: ([Int] -> Bool) -> TestOptions -> IO TestResult

Is there any way to get QuickCheck to choose a for me instead of having it specified in the type of run?



Answers

The quickcheck manual says "no":

Properties must have monomorphic types. `Polymorphic' properties, such as the one above, must be restricted to a particular type to be used for testing. It is convenient to do so by stating the types of one or more arguments in a

where types = (x1 :: t1, x2 :: t2, ...)

clause...



Open the page in firefox. However, first, download the firebug extension. Then, right click on the offending version and go down to inspect element.

Firebug is awesome because it let's you navigate the css of any element. You have two options here:

1) Assign the topmost element an css class and work it that way. or If that's not an option, you can use firebug to get the xpath to the offending element. Xpaths look like body/table/tr/td/table/tr[2]

what you want to do with that in css is

body table tr td table tr { /*css goes here */

}

Option 1 is definitely the better pick. Option 2 is more of a dirty way of getting things done when things like asp.net doesn't let us have the fine grain of control we want.

It would be really awesome if you used a pastebin and posted the link to your rendered page's html.

By : user8456


It uses the style from the grid, because it's in it. If you want to change it's style, change the style of the control. What do you want it to do?

By : McKay


This video can help you solving your question :)
By: admin