genvalidity-hspec-1.0.0.3: Standard spec's for GenValidity instances

Safe Haskell | Safe-Inferred
Language | Haskell2010

Test.Validity.Monad

Description

Monad properties

You will need `TypeApplications` to use these.

Synopsis

- monadSpec :: forall (f :: Type -> Type). (Eq (f Int), Show (f Int), Monad f, Typeable f, GenValid (f Int)) => Spec
- monadSpecOnArbitrary :: forall (f :: Type -> Type). (Eq (f Int), Show (f Int), Monad f, Typeable f, Arbitrary (f Int)) => Spec
- monadSpecOnGens :: forall (f :: Type -> Type) (a :: Type) (b :: Type) (c :: Type). (Show a, Show (f a), Show (f b), Show (f c), Eq (f a), Eq (f b), Eq (f c), Monad f, Typeable f, Typeable a, Typeable b, Typeable c) => Gen a -> String -> Gen (f a) -> String -> Gen (f b) -> String -> Gen (a -> b) -> String -> Gen (a -> f b) -> String -> Gen (b -> f c) -> String -> Gen (f (a -> b)) -> String -> Spec

# Documentation

monadSpec :: forall (f :: Type -> Type). (Eq (f Int), Show (f Int), Monad f, Typeable f, GenValid (f Int)) => Spec Source #

Standard test spec for properties of Monad instances for values generated with GenValid instances

Example usage:

    monadSpec @[]

monadSpecOnArbitrary :: forall (f :: Type -> Type). (Eq (f Int), Show (f Int), Monad f, Typeable f, Arbitrary (f Int)) => Spec Source #

Standard test spec for properties of Monad instances for values generated with Arbitrary instances

Example usage:

    monadSpecOnArbitrary @[]

monadSpecOnGens :: forall (f :: Type -> Type) (a :: Type) (b :: Type) (c :: Type). (Show a, Show (f a), Show (f b), Show (f c), Eq (f a), Eq (f b), Eq (f c), Monad f, Typeable f, Typeable a, Typeable b, Typeable c) => Gen a -> String -> Gen (f a) -> String -> Gen (f b) -> String -> Gen (a -> b) -> String -> Gen (a -> f b) -> String -> Gen (b -> f c) -> String -> Gen (f (a -> b)) -> String -> Spec Source #

Standard test spec for properties of Monad instances for values generated by given generators (and names for those generator).

Example usage:

    monadSpecOnGens
        @[]
        @Int
        (pure 4)
        "four"
        (genListOf $ pure 5)
        "list of fives"
        (genListOf $ pure 6)
        "list of sixes"
        ((*) <$> genValid)
        "factorisations"
        (pure $ \a -> [a])
        "singletonisation"
        (pure $ \a -> [a])
        "singletonisation"
        (pure $ pure (+ 1))
        "increment in list"