properties-0.0.2: check quickCheck properties in real time.




verify :: Show b => a -> [Property (b -> Bool)] -> b -> aSource

Check a list of properties. when a property is violated, a trace error is printed at the end i return the first value, just like (flip trace) must be used as opeator:

expression  verify properties with value tuple


stringProperty= Property "length" (\(x, y)-> length (x++y)== length x + length y)

main= do
        let s=  "hello "
        let s2= "world"
        print $ s++ s2        `verify` stringProperty `with`(s,s2)
        print "that's all!"

It is possible to check quickCheck style properties. The same example with a quickCheck style property:

quickCheckProperty x y=  length (x++y)== length x + length y

main= do
        let s=  "hello "
        let s2= "world"
        print $ s++ s2        `verify` [Property "stringSumLength" $ uncurry quickCheckProperty] `with`(s,s2)
        print "that's all!"

data Property a Source

A labeled property includes a string label and an expression


Property String a 

data Properties a b c Source

Properties is a convenient way to express list of properties with the same arity.




unary :: [Property (a -> Bool)]
binary :: [Property ((a, b) -> Bool)]
ternary :: [Property ((a, b, c) -> Bool)]

properties :: forall a b c. Properties a b cSource

empty properties: properties= Properties [] [] []

with :: (a -> b) -> a -> bSource

to improve readability: with= ($)