Blame examples/Simple.hs

Packit 1d8052
{-# LANGUAGE ScopedTypeVariables, TemplateHaskell #-}
Packit 1d8052
module Main where
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- imports
Packit 1d8052
Packit 1d8052
import Test.QuickCheck
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- example 1
Packit 1d8052
Packit 1d8052
allEqual  x y z = x == y && y == z
Packit 1d8052
allEqual' x y z = 2*x == y + z
Packit 1d8052
Packit 1d8052
prop_SimonThompson x y (z :: Int) =
Packit 1d8052
  allEqual x y z == allEqual' x y z
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- example 2
Packit 1d8052
Packit 1d8052
prop_ReverseReverse :: Eq a => [a] -> Bool
Packit 1d8052
prop_ReverseReverse xs =
Packit 1d8052
  reverse (reverse xs) == xs
Packit 1d8052
Packit 1d8052
prop_Reverse xs =
Packit 1d8052
  reverse xs == xs
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- example 3
Packit 1d8052
Packit 1d8052
prop_Error (x,y) =
Packit 1d8052
  2*x <= 5*y
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- main
Packit 1d8052
Packit 1d8052
return []
Packit 1d8052
prop_conj = counterexample "Simon Thompson" $(monomorphic 'prop_SimonThompson) .&&.
Packit 1d8052
            counterexample "reverse" $(monomorphic 'prop_Reverse)
Packit 1d8052
prop_disj = counterexample "reverse" $(monomorphic 'prop_Reverse) .||.
Packit 1d8052
            counterexample "Simon Thompson" $(monomorphic 'prop_SimonThompson)
Packit 1d8052
return []
Packit 1d8052
main = $quickCheckAll
Packit 1d8052
Packit 1d8052
--------------------------------------------------------------------------
Packit 1d8052
-- the end.