import Test.QuickCheck hiding (OrderedList (..), orderedList) import Data.List (sort, insert) -- In this file we want to test the `insert` function from Data.List: -- -- insert :: Ord a => a -> [a] -> [a] -- Check if a list is ordered ordered :: Ord a => [a] -> Bool ordered as = as == sort as prop_insert_bad :: Int -> [Int] -> Property prop_insert_bad a as = collect (length as) $ ordered as ==> ordered (insert a as) data OrderedList = Ordered [Int] deriving (Show, Eq) instance Arbitrary OrderedList where arbitrary = do as <- arbitrary return (Ordered (sort as)) prop_insert :: Int -> OrderedList -> Property prop_insert a (Ordered as) = collect (length as) $ ordered (insert a as) -- prop_pos -- prop_nonNeg