module ProtoQuickCheck where
import QuickCheck
import List

-- 	$Id: ProtoQuickCheck.hs,v 1.2 2003/03/11 18:09:14 shae Exp $	

prop_RevUnit :: [Int] -> Bool
prop_RevUnit x = 
    reverse [x] == [x]

prop_RevApp :: [Int] -> [Int] -> Bool
prop_RevApp xs ys = 
    reverse (xs ++ ys) == reverse ys ++ reverse xs

prop_RevRev :: [Int] -> Bool
prop_RevRev xs = 
    reverse (reverse xs) == xs

(f === g) x = f x == g x

prop_CompAssoc       :: (Int -> Int) -> (Int -> Int)  -> (Int -> Int) -> Int -> Bool
prop_CompAssoc f g h = (f . (g . h)) === ((f . g) . h)

prop_CompCommut       :: (Int -> Int) -> (Int -> Int) -> Int -> Bool
prop_CompCommut f g = (f . g) === (g . f)

instance Show (a -> b) where show _ = "<<function>>"

prop_MaxLe     :: Int -> Int -> Property
prop_MaxLe x y = x <= y ==> max x y == y


prop_Insert      :: Int -> [Int] -> Property
prop_Insert x xs =
    ordered xs ==> ordered (insert x xs)

prop_Insert2      :: Int -> [Int] -> Property
prop_Insert2 x xs =
    ordered xs ==> classify (null xs) "trivial" $ ordered (insert x xs)

prop_Insert3      :: Int -> [Int] -> Property
prop_Insert3 x xs =
    ordered xs ==> collect (length xs) $ ordered (insert x xs)

prop_DoubleCycle    :: [Int] -> Property
prop_DoubleCycle xs =
    not (null xs) ==> 
        cycle xs == cycle (xs ++ xs)

prop_DoubleCycle2      :: [Int] -> Int -> Property
prop_DoubleCycle2 xs n = 
    not (null xs) && n >= 0 ==> 
        take n (cycle xs) == take n (cycle (xs ++ xs))

-- courtesy Heffalump
ordered []       =  True
ordered [x]      =  True
ordered (x:y:xs) =  x<=y && ordered (y:xs)

-- Local Variables:
-- compile-command: "./quickcheck +names ProtoQuickCheck.hs"
-- End:

main = putStr "yo"