-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Check properties on standard classes and data structures. -- -- ''Checkers'' wraps up the expected properties associated with various -- standard type classes as QuickCheck properties. Also some morphism -- properties. It also provides arbitrary instances and generator -- combinators for common data types. -- -- Project wiki page: http://haskell.org/haskellwiki/checkers -- -- The module documentation pages have links to colorized source code and -- to wiki pages where you can read and contribute user comments. Enjoy! -- -- © 2008 by Conal Elliott; BSD3 license. -- -- Contributions from: Thomas Davie. @package checkers @version 0.1 module Test.QuickCheck.Instances.Word instance Arbitrary Word8 instance Arbitrary Word16 instance Arbitrary Word32 instance Arbitrary Word64 module Test.QuickCheck.Instances.Int instance Arbitrary Int8 instance Arbitrary Int16 instance Arbitrary Int32 instance Arbitrary Int64 module Test.QuickCheck.Instances.Array instance (Ix a, Integral a, Arbitrary b) => Arbitrary (Array a b) module Test.QuickCheck.Instances.Tuple -- | Generates a 2-tuple using its arguments to generate the parts. (>*<) :: Gen a -> Gen b -> Gen (a, b) -- | Generates a 3-tuple using its arguments to generate the parts. (>**<) :: Gen a -> Gen b -> Gen c -> Gen (a, b, c) -- | Generates a 4-tuple using its arguments to generate the parts. (>***<) :: Gen a -> Gen b -> Gen c -> Gen d -> Gen (a, b, c, d) -- | Generates a 5-tuple using its arguments to generate the parts. (>****<) :: Gen a -> Gen b -> Gen c -> Gen d -> Gen e -> Gen (a, b, c, d, e) module Test.QuickCheck.Bottoms bottom :: Gen a infiniteComp :: Gen a module Test.QuickCheck.Instances.Ord greaterThan :: (Ord a, Arbitrary a) => a -> Gen a -> Gen a lessThan :: (Ord a, Arbitrary a) => a -> Gen a -> Gen a module Test.QuickCheck.Instances.Num nonNegative :: (Num a, Arbitrary a) => Gen a nonPositive :: (Num a, Arbitrary a) => Gen a negative :: (Num a, Arbitrary a) => Gen a positive :: (Num a, Arbitrary a) => Gen a nonZero :: (Num a, Arbitrary a) => Gen a -> Gen a nonZero_ :: (Num a, Arbitrary a) => Gen a module Test.QuickCheck.Applicative instance Applicative Gen module Test.QuickCheck.Instances.List -- | Generates any list (possibly empty) with the contents generated using -- its argument. anyList :: Gen a -> Gen [a] -- | Generates a non-empty list with the contents generated using its -- argument. nonEmpty :: Gen a -> Gen [a] -- | Generates an infinite list with contents generated using its argument infiniteList :: Gen a -> Gen [a] -- | Generate increasing towards infinity increasing :: (Arbitrary a, Num a) => Gen [a] -- | Generate nondecreasing values nondecreasing :: (Arbitrary a, Num a) => Gen [a] -- | Generate an infinite list of increasing values increasingInf :: (Arbitrary a, Num a) => Gen [a] -- | Generate an infinite list of nondecreasing values nondecreasingInf :: (Arbitrary a, Num a) => Gen [a] -- | Generate increasing towards infinity decreasing :: (Arbitrary a, Num a) => Gen [a] -- | Generate nondecreasing values nonincreasing :: (Arbitrary a, Num a) => Gen [a] -- | Generate an infinite list of increasing values decreasingInf :: (Arbitrary a, Num a) => Gen [a] -- | Generate an infinite list of nondecreasing values nonincreasingInf :: (Arbitrary a, Num a) => Gen [a] module Test.QuickCheck.Instances.Maybe maybeGen :: Gen a -> Gen (Maybe a) -- | Some QuickCheck helpers module Test.QuickCheck.Checkers -- | Named test type Test = (String, Property) -- | Named batch of tests type TestBatch = (String, [Test]) -- | Flatten a test batch for inclusion in another unbatch :: TestBatch -> [Test] -- | Run a batch of tests. See quickBatch and verboseBatch. checkBatch :: Config -> TestBatch -> IO () -- | Check a batch tersely. quickBatch :: TestBatch -> IO () -- | Check a batch verbosely. verboseBatch :: TestBatch -> IO () probablisticPureCheck :: (Testable a) => Config -> a -> Bool -- | Unary function, handy for type annotations type Unop a = a -> a -- | Binary function, handy for type annotations type Binop a = a -> a -> a genR :: (Random a) => (a, a) -> Gen a -- | f is a left inverse of g. See also inverse. inverseL :: (EqProp b, Arbitrary b, Show b) => (a -> b) -> (b -> a) -> Property -- | f is a left and right inverse of g. See also -- inverseL. inverse :: (EqProp a, Arbitrary a, Show a, EqProp b, Arbitrary b, Show b) => (a -> b) -> (b -> a) -> Property -- | Token Fractional type for tests type FracT = Float -- | Token Num type for tests type NumT = Int -- | Token Ord type for tests type OrdT = Char -- | Token uninteresting type for tests type T = Char -- | Types of values that can be tested for equality, perhaps through -- random sampling. class EqProp a (=-=) :: (EqProp a) => a -> a -> Property -- | For Eq types as EqProp types eq :: (Eq a) => a -> a -> Property -- | Has a given left identity, according to '(=-=)' leftId :: (Show a, Arbitrary a, EqProp a) => (i -> a -> a) -> i -> Property -- | Has a given right identity, according to '(=-=)' rightId :: (Show a, Arbitrary a, EqProp a) => (a -> i -> a) -> i -> Property -- | Has a given left and right identity, according to '(=-=)' bothId :: (Show a, Arbitrary a, EqProp a) => (a -> a -> a) -> a -> Property -- | Associative, according to '(=-=)' isAssoc :: (EqProp a, Show a, Arbitrary a) => (a -> a -> a) -> Property -- | Commutative, according to '(=-=)' isCommut :: (EqProp a, Show a, Arbitrary a) => (a -> a -> a) -> Property -- | Commutative, according to '(=-=)' commutes :: (EqProp z) => (a -> a -> z) -> a -> a -> Property -- | Explicit Monoid dictionary. Doesn't have to correspond to an -- actual Monoid instance, though see monoidD. data MonoidD a -- | Monoid dictionary built from the Monoid methods. monoidD :: (Monoid a) => MonoidD a -- | Monoid dictionary for an unwrapped endomorphism. See also -- monoidD and Endo. endoMonoidD :: MonoidD (a -> a) -- | Homomorphism properties with respect to given monoid dictionaries. See -- also monoidMorphism. homomorphism :: (EqProp b, Show a, Arbitrary a) => MonoidD a -> MonoidD b -> (a -> b) -> [(String, Property)] -- | The unary function f is idempotent, i.e., f . f == f idempotent :: (Show a, Arbitrary a, EqProp a) => (a -> a) -> Property -- | A binary function op is idempotent, i.e., x op x -- == x, for all x idempotent2 :: (Show a, Arbitrary a, EqProp a) => (a -> a -> a) -> Property -- | A binary function op is has an idempotent element x, -- i.e., x op x == x idemElem :: (EqProp a) => (a -> a -> a) -> a -> Property class Model a b | a -> b model :: (Model a b) => a -> b meq :: (Model a b, EqProp b) => a -> b -> Property meq1 :: (Model a b, Model a1 b1, EqProp b) => (a1 -> a) -> (b1 -> b) -> a1 -> Property meq2 :: (Model a b, Model a1 b1, Model a2 b2, EqProp b) => (a1 -> a2 -> a) -> (b1 -> b2 -> b) -> a1 -> a2 -> Property meq3 :: (Model a b, Model a1 b1, Model a2 b2, Model a3 b3, EqProp b) => (a1 -> a2 -> a3 -> a) -> (b1 -> b2 -> b3 -> b) -> a1 -> a2 -> a3 -> Property meq4 :: (Model a b, Model a1 b1, Model a2 b2, Model a3 b3, Model a4 b4, EqProp b) => (a1 -> a2 -> a3 -> a4 -> a) -> (b1 -> b2 -> b3 -> b4 -> b) -> a1 -> a2 -> a3 -> a4 -> Property meq5 :: (Model a b, Model a1 b1, Model a2 b2, Model a3 b3, Model a4 b4, Model a5 b5, EqProp b) => (a1 -> a2 -> a3 -> a4 -> a5 -> a) -> (b1 -> b2 -> b3 -> b4 -> b5 -> b) -> a1 -> a2 -> a3 -> a4 -> a5 -> Property eqModels :: (Model a b, EqProp b) => a -> a -> Property -- | Like Model but for unary type constructors. class Model1 f g | f -> g model1 :: (Model1 f g) => f a -> g a type Positive a = NonZero (NonNegative a) newtype NonZero a NonZero :: a -> NonZero a unNonZero :: NonZero a -> a newtype NonNegative a NonNegative :: a -> NonNegative a unNonNegative :: NonNegative a -> a -- | Generates a value that satisfies a predicate. suchThat :: Gen a -> (a -> Bool) -> Gen a -- | Tries to generate a value that satisfies a predicate. suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a) -- | Generate n arbitrary values arbs :: (Arbitrary a) => Int -> IO [a] -- | Produce n values from a generator gens :: Int -> Gen a -> IO [a] -- | Property conjunction (.&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property arbitrarySatisfying :: (Arbitrary a) => (a -> Bool) -> Gen a instance (Eq a) => Eq (NonNegative a) instance (Ord a) => Ord (NonNegative a) instance (Num a) => Num (NonNegative a) instance (Integral a) => Integral (NonNegative a) instance (Real a) => Real (NonNegative a) instance (Enum a) => Enum (NonNegative a) instance (Show a) => Show (NonNegative a) instance (Read a) => Read (NonNegative a) instance (Eq a) => Eq (NonZero a) instance (Ord a) => Ord (NonZero a) instance (Num a) => Num (NonZero a) instance (Integral a) => Integral (NonZero a) instance (Real a) => Real (NonZero a) instance (Enum a) => Enum (NonZero a) instance (Show a) => Show (NonZero a) instance (Read a) => Read (NonZero a) instance (Testable a, Testable b) => Testable (a, b) instance (Testable a) => Testable [a] instance (Num a, Arbitrary a) => Arbitrary (NonNegative a) instance (Num a, Arbitrary a) => Arbitrary (NonZero a) instance (Model a b, Model a' b') => Model (a, a') (b, b') instance Model String String instance Model Double Double instance Model Float Float instance Model Int Int instance Model Char Char instance Model Bool Bool instance (Show a, Arbitrary a, EqProp b) => EqProp (a -> b) instance (EqProp a, EqProp b) => EqProp (Either a b) instance (EqProp a, EqProp b) => EqProp (a, b) instance (EqProp a) => EqProp (Maybe a) instance (EqProp a) => EqProp [a] instance EqProp Double instance EqProp Int instance EqProp Char instance EqProp Bool module Test.QuickCheck.Instances.Eq notEqualTo :: (Eq a, Arbitrary a) => a -> Gen a -> Gen a notOneof :: (Eq a, Arbitrary a) => [a] -> Gen a module Test.QuickCheck.Instances.Char -- | Generates a 'non space' character, i.e. any ascii except ' ', '\t', -- '\n' and '\r'. nonSpace :: Gen Char -- | Generates any whitespace character, including new lines. whitespace :: Gen Char -- | Generates a whitespace charecter, not a newline. space :: Gen Char -- | Generates either a '\n' or '\r'. newline :: Gen Char -- | Generates any lower case alpha character. lowerAlpha :: Gen Char -- | Generates any upper case alpha character. upperAlpha :: Gen Char -- | Generates a digit character. numeric :: Gen Char -- | Generates one or other of '(' and ')'. parenthesis :: Gen Char -- | Generates one or other of '[' and ']'. bracket :: Gen Char -- | Generates one or other of '{' and '}'. brace :: Gen Char -- | Generates one of *, /, -, +, <, -- >, '|' and '#'. operator :: Gen Char instance Arbitrary Char module Test.QuickCheck.Instances -- | Some QuickCheck properties for standard type classes module Test.QuickCheck.Classes -- | Properties to check that the Monoid a satisfies the -- monoid properties. The argument value is ignored and is present only -- for its type. monoid :: (Monoid a, Show a, Arbitrary a, EqProp a) => a -> TestBatch -- | Monoid homomorphism properties. See also homomorphism. monoidMorphism :: (Monoid a, Monoid b, EqProp b, Show a, Arbitrary a) => (a -> b) -> TestBatch semanticMonoid :: (Model a b, Monoid a, Monoid b, Show a, Arbitrary a, EqProp b) => a -> TestBatch -- | Properties to check that the Functor m satisfies the -- functor properties. functor :: (Functor m, Arbitrary a, Arbitrary b, Arbitrary c, Show (m a), Arbitrary (m a), EqProp (m a), EqProp (m c)) => m (a, b, c) -> TestBatch -- | Functor morphism (natural transformation) properties functorMorphism :: (Functor f, Functor g, Arbitrary (f NumT), Show (f NumT), EqProp (g T)) => (forall a. f a -> g a) -> TestBatch semanticFunctor :: (Model1 f g, Functor f, Functor g, Arbitrary (f NumT), Show (f NumT), EqProp (g T)) => f () -> TestBatch functorMonoid :: (Functor m, Monoid (m a), Monoid (m b), Arbitrary (a -> b), Arbitrary (m a), Show (m a), EqProp (m b)) => m (a, b) -> TestBatch -- | Properties to check that the Applicative m satisfies -- the monad properties applicative :: (Applicative m, Arbitrary a, Arbitrary b, Arbitrary (m a), Arbitrary (m (b -> c)), Show (m (b -> c)), Arbitrary (m (a -> b)), Show (m (a -> b)), Show a, Show (m a), EqProp (m a), EqProp (m b), EqProp (m c)) => m (a, b, c) -> TestBatch -- | Applicative morphism properties applicativeMorphism :: (Applicative f, Applicative g, Show (f NumT), Arbitrary (f NumT), EqProp (g NumT), EqProp (g T), Show (f (NumT -> T)), Arbitrary (f (NumT -> T))) => (forall a. f a -> g a) -> TestBatch semanticApplicative :: (Model1 f g, Applicative f, Applicative g, Arbitrary (f NumT), Arbitrary (f (NumT -> T)), EqProp (g NumT), EqProp (g T), Show (f NumT), Show (f (NumT -> T))) => f () -> TestBatch -- | Properties to check that the Monad m satisfies the -- monad properties monad :: (Monad m, Show a, Arbitrary a, Arbitrary b, Arbitrary (m a), EqProp (m a), Show (m a), Arbitrary (m b), EqProp (m b), Arbitrary (m c), EqProp (m c)) => m (a, b, c) -> TestBatch -- | Monad morphism properties -- -- Applicative morphism properties monadMorphism :: (Monad f, Monad g, Functor g, Show (f NumT), Show (f (NumT -> T)), Show (f (f (NumT -> T))), Arbitrary (f NumT), Arbitrary (f T), Arbitrary (f (NumT -> T)), Arbitrary (f (f (NumT -> T))), EqProp (g NumT), EqProp (g T), EqProp (g (NumT -> T))) => (forall a. f a -> g a) -> TestBatch semanticMonad :: (Model1 f g, Monad f, Monad g, EqProp (g T), EqProp (g NumT), EqProp (g (NumT -> T)), Arbitrary (f T), Arbitrary (f NumT), Arbitrary (f (f (NumT -> T))), Arbitrary (f (NumT -> T)), Show (f (f (NumT -> T))), Show (f (NumT -> T)), Show (f NumT), Functor g) => f () -> TestBatch -- | Law for monads that are also instances of Functor. monadFunctor :: (Functor m, Monad m, Arbitrary a, Arbitrary b, Arbitrary (m a), Show (m a), EqProp (m b)) => m (a, b) -> TestBatch monadApplicative :: (Applicative m, Monad m, EqProp (m a), EqProp (m b), Show a, Arbitrary a, Show (m a), Arbitrary (m a), Show (m (a -> b)), Arbitrary (m (a -> b))) => m (a, b) -> TestBatch arrow :: (Arrow ~>, Show (d ~> e), Show (c ~> d), Show (b ~> c), Show b, Show c, Show d, Show e, Arbitrary (d ~> e), Arbitrary (c ~> d), Arbitrary (b ~> c), Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, EqProp (b ~> e), EqProp (b ~> d), EqProp ((b, d) ~> c), EqProp ((b, d) ~> (c, d)), EqProp ((b, e) ~> (d, e)), EqProp ((b, d) ~> (c, e)), EqProp b, EqProp c, EqProp d, EqProp e) => b ~> (c, d, e) -> TestBatch arrowChoice :: (ArrowChoice ~>, Show (b ~> c), Arbitrary (b ~> c), Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, EqProp ((Either b d) ~> (Either c e)), EqProp ((Either b d) ~> (Either c d))) => b ~> (c, d, e) -> TestBatch traversable :: (Traversable f, Monoid m, Show (f a), Arbitrary (f a), Arbitrary b, Arbitrary a, Arbitrary m, EqProp (f b), EqProp m) => f (a, b, m) -> TestBatch -- | Laws for MonadPlus instances with left distribution. monadPlus :: (MonadPlus m, Show (m a), Arbitrary a, Arbitrary (m a), Arbitrary (m b), EqProp (m a), EqProp (m b)) => m (a, b) -> TestBatch -- | Laws for MonadPlus instances with left catch. monadOr :: (MonadPlus m, Show a, Show (m a), Arbitrary a, Arbitrary (m a), Arbitrary (m b), EqProp (m a), EqProp (m b)) => m (a, b) -> TestBatch -- | Later. Allows for testing of functions that depend on the order of -- evaluation. -- -- TODO: move this functionality to the testing package for Unamb. module Test.QuickCheck.Later -- | Is the given function associative when restricted to the same value -- but possibly different times? isAssocTimes :: (EqProp a, Arbitrary a, Show a) => Double -> (a -> a -> a) -> Property -- | Is the given function commutative when restricted to the same value -- but possibly different times? isCommutTimes :: (EqProp b, Arbitrary a, Show a) => Double -> (a -> a -> b) -> Property -- | Delay a value's availability by the given duration in seconds. Note -- that the delay happens only on the first evaluation. delay :: (RealFrac t) => t -> a -> a -- | A value that is never available. Rerun of hang from unamb, -- but replicated to avoid mutual dependency. -- -- TODO: Remove when this module is moved into the unamb-test package. delayForever :: a