Posts

Showing posts from August, 2020

Property testing property testers

Show the Haskell imports import Numeric.Natural import Data.Maybe Property testers such as QuickCheck are used to search for inputs that invalidate a given property. We focus on properties that are implemented in Haskell as a function a -> Bool . In the context of QuickCheck, the type a is assumed to be an instance of the Arbitrary type class, allowing to randomly generate values of a . Because of its random nature, QuickCheck might not find any offending element of a even if it exists. type Property a = a -> Bool If the property tester managed to invalidate the property, it returns the offending element of a . Otherwise, it simply succeeds. data Result counterexample = Success | Failure counterexample instance Show ( Result counterexample) where show Success = "Success" show ( Failure _) = "Failure" type Tester a = Property a -> Result a It is quite well-known in the functional programming community that...