proarrow:testing
Safe HaskellNone
LanguageGHC2024

Proarrow.Testing

Description

Generic property-testing infrastructure for categories: Testable says how to generate and enumerate the objects of a kind, TestableProfunctor and TestableType how to generate values (using falsify generators), and TestingEqShow provides semantic equality and display for values without useful structural Eq/Show (functions, opaque morphisms). Instances for your own category plus the law checks in Proarrow.Testing.Laws give it a test suite.

Synopsis

Describing a category

class (TestableProfunctor (Hom k), TestableTypeP (Hom k), CategoryOf k) => Testable k where Source Github #

A kind whose objects can be enumerated and displayed.

Minimal complete definition

showOb, genSome

Associated Types

type TestOb (a :: k) Source Github #

type TestOb (a :: k) = Ob a

Methods

showOb :: forall (a :: k). TestOb a => String Source Github #

genSome :: Gen (Some k) Source Github #

obFromTestOb :: forall (a :: k) r. TestOb a => (Ob a => r) -> r Source Github #

default obFromTestOb :: forall (a :: k) r. (TestOb a ~ Ob a, TestOb a) => (Ob a => r) -> r Source Github #

genSomeSmall :: Gen (Some k) Source Github #

The palette for properties whose cost grows steeply with object size: in practice those that enumerate an internal hom, which is brute force over tables and doubly exponential (an object with hom-sizes [2,4,2,4] has the hom into it at [1024,256,1024,256]). Defaults to genSome. Override it only when genSome draws objects too big for testClosed to terminate.

An instance that wraps another kind's palette must forward this too, as the wrapper instances below do, or testClosed silently gets the wide one.

Instances

Instances details
Testable () Source Github # 
Instance details

Defined in Proarrow.Testing

Associated Types

type TestOb (a :: ()) 
Instance details

Defined in Proarrow.Testing

type TestOb (a :: ()) = Ob a

Methods

showOb :: forall (a :: ()). TestOb a => String Source Github #

genSome :: Gen (Some ()) Source Github #

obFromTestOb :: forall (a :: ()) r. TestOb a => (Ob a => r) -> r Source Github #

genSomeSmall :: Gen (Some ()) Source Github #

Testable k => Testable (OPPOSITE k) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

showOb :: forall (a :: OPPOSITE k). TestOb a => String Source Github #

genSome :: Gen (Some (OPPOSITE k)) Source Github #

obFromTestOb :: forall (a :: OPPOSITE k) r. TestOb a => (Ob a => r) -> r Source Github #

genSomeSmall :: Gen (Some (OPPOSITE k)) Source Github #

Testable k => Testable (PROD k) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

showOb :: forall (a :: PROD k). TestOb a => String Source Github #

genSome :: Gen (Some (PROD k)) Source Github #

obFromTestOb :: forall (a :: PROD k) r. TestOb a => (Ob a => r) -> r Source Github #

genSomeSmall :: Gen (Some (PROD k)) Source Github #

(Testable j, Testable k) => Testable (j, k) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

showOb :: forall (a :: (j, k)). TestOb a => String Source Github #

genSome :: Gen (Some (j, k)) Source Github #

obFromTestOb :: forall (a :: (j, k)) r. TestOb a => (Ob a => r) -> r Source Github #

genSomeSmall :: Gen (Some (j, k)) Source Github #

class (Testable j, Testable k, Profunctor p, forall (a :: k) (b :: j). (TestOb a, TestOb b) => TestingEqShow (p a b)) => TestableProfunctor (p :: j +-> k) where Source Github #

Minimal complete definition

Nothing

Methods

genProfunctorElt :: String -> Property (SomeProfunctorElt p) Source Github #

The default implementation generates an object a, then an object b for which p a b has elements (see genObSuchThat), and then a value of type p a b.

Instances

Instances details
TestableProfunctor Unit Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, FiniteCat j, FiniteCat k) => TestableProfunctor (Sieve :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k) => TestableProfunctor (TerminalProfunctor :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, HasFiniteCovers t k, FiniteCat j, FiniteCat k) => TestableProfunctor (ClosedSieve t :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k) => TestableProfunctor (Plus t p :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(TestableProfunctor p, TestableProfunctor q, TestableTypeP p, TestableTypeP q) => TestableProfunctor (p :+: q :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, Finitary p, Finitary q, FiniteCat j, FiniteCat k) => TestableProfunctor (p :~>: q :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(TestableProfunctor p, TestableProfunctor q, TestableTypeP p, TestableTypeP q) => TestableProfunctor (p :*: q :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, TestOb x, TestOb b) => TestableProfunctor (Yo x ('OP b) :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, FiniteCat j, FiniteCat k, KnownTables j k lm rm) => TestableProfunctor (Tabulated t lm rm :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, Finitary v, Finitary p, FiniteCat i, FiniteCat k) => TestableProfunctor (Ran ('OP v) p :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, Finitary w, Finitary p, FiniteCat i, FiniteCat j) => TestableProfunctor (Rift ('OP w) p :: k -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

TestableProfunctor p => TestableProfunctor (Op p :: OPPOSITE j -> OPPOSITE k -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

TestableProfunctor p => TestableProfunctor (Prod p :: PROD k -> PROD j -> Type) Source Github #

The PROD wrapper changes only which tensor a kind carries, so everything transports across it.

Instance details

Defined in Proarrow.Testing

(TestableProfunctor p, TestableProfunctor q) => TestableProfunctor (p :**: q :: (k1, k2) -> (j1, j2) -> Type) Source Github # 
Instance details

Defined in Proarrow.Testing

class TestingEqShow a => TestableType a where Source Github #

Methods

gen :: GenTotal a Source Github #

Instances

Instances details
(Ob a, Ob b) => TestableType (Unit a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Unit a b) Source Github #

(Function a, TestableType a, TestableType b) => TestableType (a -> b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (a -> b) Source Github #

(Finitary p, Finitary q, FiniteCat j, FiniteCat k) => TestableType (Prof p q) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Prof p q) Source Github #

(Testable j, Testable k, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestableType (Sieve a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Sieve a b) Source Github #

(Testable j, Testable k, TestOb a, TestOb b) => TestableType (TerminalProfunctor a b) Source Github # 
Instance details

Defined in Proarrow.Testing

(Testable j, Testable k, HasFiniteCovers t k, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestableType (ClosedSieve t a b) Source Github # 
Instance details

Defined in Proarrow.Testing

TestableType (p b a) => TestableType (Op p ('OP a) ('OP b)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Op p ('OP a) ('OP b)) Source Github #

(Finitary (Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) :: SUBCAT ob -> SUBCAT ob -> Type), Finitary p, Finitary q, FiniteCat j, FiniteCat k, ob p, ob q) => TestableType (Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob)) Source Github #

TestableType (p a b) => TestableType (Prod p ('PR a) ('PR b)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Prod p ('PR a) ('PR b)) Source Github #

(TestableType ((f @ a) ~> b), Ob a) => TestableType (Corep f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Corep f a b) Source Github #

(Ob a, TestableType (f a ~> b)) => TestableType (Costar f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Costar f a b) Source Github #

(Ob b, TestableType (a ~> f b)) => TestableType (Star f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Star f a b) Source Github #

(TestableType (a ~> (f @ b)), Ob b) => TestableType (Rep f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Rep f a b) Source Github #

(Testable j, Testable k, HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestableType (Plus t p a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Plus t p a b) Source Github #

(TestableType (p a b), TestableType (q a b)) => TestableType ((p :+: q) a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal ((p :+: q) a b) Source Github #

(Testable j, Testable k, Finitary p, Finitary q, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestableType ((p :~>: q) a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal ((p :~>: q) a b) Source Github #

(TestableType (p a b), TestableType (q a b)) => TestableType ((p :*: q) a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal ((p :*: q) a b) Source Github #

(Testable j, Testable k, TestOb a, TestOb x, TestOb b, TestOb c) => TestableType (Yo x ('OP b) a c) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Yo x ('OP b) a c) Source Github #

(Testable j, Testable k, FiniteCat j, FiniteCat k, KnownTables j k lm rm, TestOb a, TestOb b) => TestableType (Tabulated t lm rm a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Tabulated t lm rm a b) Source Github #

(Testable j, Testable k, Finitary v, Finitary p, FiniteCat i, FiniteCat k, TestOb a, TestOb b) => TestableType (Ran ('OP v) p a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Ran ('OP v) p a b) Source Github #

(Testable j, Testable k, Finitary w, Finitary p, FiniteCat i, FiniteCat j, TestOb a, TestOb b) => TestableType (Rift ('OP w) p a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal (Rift ('OP w) p a b) Source Github #

(TestableType (catk a1 b1), TestableType (catj a2 b2)) => TestableType ((catk :**: catj) '(a1, a2) '(b1, b2)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

gen :: GenTotal ((catk :**: catj) '(a1, a2) '(b1, b2)) Source Github #

class (forall (a :: k) (b :: j). (TestOb a, TestOb b) => TestableType (p a b)) => TestableTypeP (p :: j +-> k) Source Github #

Instances

Instances details
(forall (a :: k) (b :: j). (TestOb a, TestOb b) => TestableType (p a b)) => TestableTypeP (p :: j +-> k) Source Github # 
Instance details

Defined in Proarrow.Testing

class TestingEqShow a where Source Github #

Minimal complete definition

Nothing

Methods

eqP :: a -> a -> Property Bool Source Github #

default eqP :: Eq a => a -> a -> Property Bool Source Github #

showP :: a -> String Source Github #

default showP :: Show a => a -> String Source Github #

Instances

Instances details
TestingEqShow (Unit a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Unit a b -> Unit a b -> Property Bool Source Github #

showP :: Unit a b -> String Source Github #

(TestableType a, TestingEqShow b) => TestingEqShow (a -> b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: (a -> b) -> (a -> b) -> Property Bool Source Github #

showP :: (a -> b) -> String Source Github #

(Finitary p, Finitary q, FiniteCat j, FiniteCat k) => TestingEqShow (Prof p q) Source Github #

A natural transformation between finitary profunctors, compared and shown by its table and drawn from natTransformations. The hom-sets of a category of finitary profunctors, with or without the SUBCAT wrapper.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Prof p q -> Prof p q -> Property Bool Source Github #

showP :: Prof p q -> String Source Github #

(FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestingEqShow (Sieve a b) Source Github #

A sieve is a table of booleans over the points of the representable, and Finitary numbers the sieves at each pair of objects. So a sieve can be generated by picking one, and compared and shown by its table. Without this, nothing that quantifies over sieves as elements of a profunctor (such as propNaturalTransformation) can run at Sieve.

Drawing one enumerates every sieve at that pair of objects, a count exponential in the size of the representable, so this is the generator to look at first if a suite gets slow.

The TestOb constraints pin j and k, which Sieve a b does not mention.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Sieve a b -> Sieve a b -> Property Bool Source Github #

showP :: Sieve a b -> String Source Github #

TestingEqShow (TerminalProfunctor a b) Source Github #

The terminal profunctor has one element at every pair of objects.

Instance details

Defined in Proarrow.Testing

(FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestingEqShow (ClosedSieve t a b) Source Github #

A closed sieve is a sieve, and is compared and shown as one. Drawing one is dearer still than drawing a sieve: the closed ones are found by taking the closure of every sieve at the pair.

Instance details

Defined in Proarrow.Testing

TestingEqShow (p b a) => TestingEqShow (Op p ('OP a) ('OP b)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Op p ('OP a) ('OP b) -> Op p ('OP a) ('OP b) -> Property Bool Source Github #

showP :: Op p ('OP a) ('OP b) -> String Source Github #

(Finitary p, Finitary q, FiniteCat j, FiniteCat k) => TestingEqShow (Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob)) Source Github #

A hom-set of a full subcategory of finitary profunctors (FINITARY, or the sheaves of Proarrow.Category.Enriched.Finitary.Sheaf) is enumerable, by natTransformations, so it can be generated. Without that a category of profunctors would not be testable at all. Equality and display go through the table of indices, there being nothing else to see of a natural transformation. (The table is cheaper than the index into elements would be, which has to search for it.)

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob) -> Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob) -> Property Bool Source Github #

showP :: Sub (Prof :: (j +-> k) -> (j +-> k) -> Type) ('SUB p :: SUBCAT ob) ('SUB q :: SUBCAT ob) -> String Source Github #

TestingEqShow (p a b) => TestingEqShow (Prod p ('PR a) ('PR b)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Prod p ('PR a) ('PR b) -> Prod p ('PR a) ('PR b) -> Property Bool Source Github #

showP :: Prod p ('PR a) ('PR b) -> String Source Github #

(TestingEqShow ((f @ a) ~> b), Ob a) => TestingEqShow (Corep f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Corep f a b -> Corep f a b -> Property Bool Source Github #

showP :: Corep f a b -> String Source Github #

TestingEqShow (f a ~> b) => TestingEqShow (Costar f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Costar f a b -> Costar f a b -> Property Bool Source Github #

showP :: Costar f a b -> String Source Github #

TestingEqShow (a ~> f b) => TestingEqShow (Star f a b) Source Github #

The elements of Star and Costar are arrows, and are compared, shown and drawn as those.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Star f a b -> Star f a b -> Property Bool Source Github #

showP :: Star f a b -> String Source Github #

(TestingEqShow (a ~> (f @ b)), Ob b) => TestingEqShow (Rep f a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Rep f a b -> Rep f a b -> Property Bool Source Github #

showP :: Rep f a b -> String Source Github #

(HasFiniteCovers t k, Finitary p, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestingEqShow (Plus t p a b) Source Github #

Compared by samePlus and shown by plusTable. See Plus for what a value stands for.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Plus t p a b -> Plus t p a b -> Property Bool Source Github #

showP :: Plus t p a b -> String Source Github #

(TestingEqShow (p a b), TestingEqShow (q a b)) => TestingEqShow ((p :+: q) a b) Source Github #

An element of a coproduct of profunctors is an element of one side, tagged.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: (p :+: q) a b -> (p :+: q) a b -> Property Bool Source Github #

showP :: (p :+: q) a b -> String Source Github #

(Finitary p, Finitary q, FiniteCat j, FiniteCat k, TestOb a, TestOb b) => TestingEqShow ((p :~>: q) a b) Source Github #

An element of the internal hom is a natural transformation out of a weight, which Finitary numbers; compare and show it by that number, as Tabulated is. Drawing one enumerates them all, so an exponential is expensive to quantify over.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: (p :~>: q) a b -> (p :~>: q) a b -> Property Bool Source Github #

showP :: (p :~>: q) a b -> String Source Github #

(TestingEqShow (p a b), TestingEqShow (q a b)) => TestingEqShow ((p :*: q) a b) Source Github #

An element of a product of profunctors is a pair of elements.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: (p :*: q) a b -> (p :*: q) a b -> Property Bool Source Github #

showP :: (p :*: q) a b -> String Source Github #

(Testable j, Testable k, TestOb a, TestOb x, TestOb b, TestOb c) => TestingEqShow (Yo x ('OP b) a c) Source Github #

An element of the Yoneda embedding is an arrow into x paired with an arrow out of b, so it is testable wherever both categories are. So a representable can be used as a test fixture, at either variance.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Yo x ('OP b) a c -> Yo x ('OP b) a c -> Property Bool Source Github #

showP :: Yo x ('OP b) a c -> String Source Github #

TestingEqShow (Tabulated t lm rm a b) Source Github #

A Tabulated value is its index, so equality and display are the index's.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Tabulated t lm rm a b -> Tabulated t lm rm a b -> Property Bool Source Github #

showP :: Tabulated t lm rm a b -> String Source Github #

(Testable j, Testable k, Finitary v, Finitary p, FiniteCat i, FiniteCat k, TestOb a, TestOb b) => TestingEqShow (Ran ('OP v) p a b) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: Ran ('OP v) p a b -> Ran ('OP v) p a b -> Property Bool Source Github #

showP :: Ran ('OP v) p a b -> String Source Github #

(Testable j, Testable k, Finitary w, Finitary p, FiniteCat i, FiniteCat j, TestOb a, TestOb b) => TestingEqShow (Rift ('OP w) p a b) Source Github #

The right Kan lift and extension of finitary profunctors, compared and shown by index, as the internal hom is.

Instance details

Defined in Proarrow.Testing

Methods

eqP :: Rift ('OP w) p a b -> Rift ('OP w) p a b -> Property Bool Source Github #

showP :: Rift ('OP w) p a b -> String Source Github #

(TestingEqShow (catk a1 b1), TestingEqShow (catj a2 b2)) => TestingEqShow ((catk :**: catj) '(a1, a2) '(b1, b2)) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

eqP :: (catk :**: catj) '(a1, a2) '(b1, b2) -> (catk :**: catj) '(a1, a2) '(b1, b2) -> Property Bool Source Github #

showP :: (catk :**: catj) '(a1, a2) '(b1, b2) -> String Source Github #

class (Testable k, forall (a :: k). Ob a => TestOb' a) => TestObIsOb k Source Github #

Instances

Instances details
(Testable k, forall (a :: k). Ob a => TestOb' a) => TestObIsOb k Source Github # 
Instance details

Defined in Proarrow.Testing

class TestOb a => TestOb' (a :: k) Source Github #

Instances

Instances details
TestOb a => TestOb' (a :: k) Source Github # 
Instance details

Defined in Proarrow.Testing

testObFromOb :: forall {k} (a :: k) r. (TestObIsOb k, Ob a) => (TestOb a => r) -> r Source Github #

Recover TestOb a from Ob a where TestObIsOb provides it: the converse of 'obFromTestOb @_', a function for the same reason.

Objecthood witnesses

type WithTestOb k = forall (a :: k) r. Ob a => (TestOb a => r) -> r Source Github #

How TestOb is closed under the structure a law-checker is about.

Every law-checker in Proarrow.Testing.Laws that needs one takes it as an explicit rank-2 argument, since in general a category may make only some of its objects testable; the _-suffixed variants supply the trivial witness. These synonyms only name the shapes, which would otherwise be spelled out in forty-odd signatures.

type WithTestOb2 k = forall (a :: k) (b :: k) r. (TestOb a, TestOb b) => (TestOb (a ** b) => r) -> r Source Github #

TestOb is closed under the tensor.

type WithTestObProd k = forall (a :: k) (b :: k) r. (TestOb a, TestOb b) => (TestOb (a && b) => r) -> r Source Github #

TestOb is closed under the binary product.

type WithTestObCoprod k = forall (a :: k) (b :: k) r. (TestOb a, TestOb b) => (TestOb (a || b) => r) -> r Source Github #

TestOb is closed under the binary coproduct.

type WithTestObExp k = forall (a :: k) (b :: k) r. (TestOb a, TestOb b) => (TestOb (a ~~> b) => r) -> r Source Github #

TestOb is closed under the internal hom.

type WithTestObDual k = forall (a :: k) r. TestOb a => (TestOb (Dual a) => r) -> r Source Github #

TestOb is closed under dualization.

type WithTestObRep k1 (p :: k1 +-> k) = forall (a :: k1) r. TestOb a => (TestOb (p % a) => r) -> r Source Github #

TestOb is closed under a representable profunctor.

type WithTestObCorep k1 (p :: k +-> k1) = forall (a :: k1) r. TestOb a => (TestOb (p %% a) => r) -> r Source Github #

TestOb is closed under a corepresentable profunctor.

Objects

type Some k = SomeOf (TestOb' :: k -> Constraint) Source Github #

A testable object of k.

data SomeOf (c :: OB k) where Github #

Some type with the evidence c, which one known only at runtime.

Constructors

Some :: forall {k} {c :: OB k} (x :: k). c x => SomeOf c 

Instances

Instances details
Testable k => Show (Some k) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

showsPrec :: Int -> Some k -> ShowS Github #

show :: Some k -> String Github #

showList :: [Some k] -> ShowS Github #

Show (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Github # 
Instance details

Defined in Proarrow.Object

Eq (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Github # 
Instance details

Defined in Proarrow.Object

Methods

(==) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(/=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

Ord (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Github # 
Instance details

Defined in Proarrow.Object

Methods

compare :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Ordering Github #

(<) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(<=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(>) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(>=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

max :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) Github #

min :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) Github #

mapSome :: forall (f :: j -> k) -> (forall (a :: j). TestOb a => TestOb' (f a)) => Some j -> Some k Source Github #

genObSmall :: Testable k => Property (Some k) Source Github #

genOb from the small palette. See genSomeSmall.

genObSuchThat :: Testable k => (Some k -> Bool) -> Property (Some k) Source Github #

genOb, but resampled (see genSuchThat) until isUsable accepts the object.

genObSuchThatWith :: Testable k => Gen (Some k) -> (Some k -> Bool) -> Property (Some k) Source Github #

genObSuchThat with objects drawn from the given generator, e.g. genSomeSmall.

genSomeDef :: forall {k} (obs :: [k]). (Testable k, KnownListOf (TestOb' :: k -> Constraint) obs) => Gen (Some k) Source Github #

genSomeFinite :: (Enumerable k, TestObIsOb k) => Gen (Some k) Source Github #

The palette of a category that already knows its own objects: Objects k is the list genSomeDef would otherwise be given by hand, and writing it twice lets the two drift apart. Only for kinds that really are finite categories. A palette like "four cardinalities out of infinitely many" is a sample, not an enumeration, and has to stay hand-picked.

mkSomeList :: forall {k} (as :: [k]). KnownListOf (TestOb' :: k -> Constraint) as => [Some k] Source Github #

The objects of a type-level list.

Profunctor elements

data SomeProfunctorElt (p :: j +-> k) where Source Github #

Constructors

SomeP :: forall {k} {j} (a :: k) (b :: j) (p :: j +-> k). (TestOb a, TestOb b) => p a b -> SomeProfunctorElt p 

Instances

Instances details
(forall (a :: k) (b :: j). (TestOb a, TestOb b) => TestingEqShow (p a b), Testable k, Testable j) => Show (SomeProfunctorElt p) Source Github # 
Instance details

Defined in Proarrow.Testing

someP :: forall {k} {j} p (a :: j) (b :: k). (Profunctor p, TestObIsOb j, TestObIsOb k) => p a b -> SomeProfunctorElt p Source Github #

Generators

falsify generators, wrapped so that an empty type is a first-class case rather than a generator that fails at run time: match GenEmpty first, then GenNonEmpty. The two are a COMPLETE set. The representation behind GenNonEmpty is not exported on purpose. Go through the pattern, which is total.

data GenTotal a where Source Github #

Constructors

GenEmpty :: forall a. ~(forall x. a -> x) -> GenTotal a 

Instances

Instances details
Alternative GenTotal Source Github # 
Instance details

Defined in Proarrow.Testing

Applicative GenTotal Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

pure :: a -> GenTotal a Github #

(<*>) :: GenTotal (a -> b) -> GenTotal a -> GenTotal b Github #

liftA2 :: (a -> b -> c) -> GenTotal a -> GenTotal b -> GenTotal c Github #

(*>) :: GenTotal a -> GenTotal b -> GenTotal b Github #

(<*) :: GenTotal a -> GenTotal b -> GenTotal a Github #

Functor GenTotal Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

fmap :: (a -> b) -> GenTotal a -> GenTotal b Github #

(<$) :: a -> GenTotal b -> GenTotal a Github #

Monad GenTotal Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

(>>=) :: GenTotal a -> (a -> GenTotal b) -> GenTotal b Github #

(>>) :: GenTotal a -> GenTotal b -> GenTotal b Github #

return :: a -> GenTotal a Github #

invmap :: (a -> b) -> (b -> a) -> GenTotal a -> GenTotal b Source Github #

isGenNonEmpty :: TestableType a => Bool Source Github #

True if a type's generator is non-empty. A pure check on TestableTypes gen. It doesn't sample anything, so it is cheap to call as often as convenient, e.g. once in a genSuchThat predicate and again in the gen/genNamed call that produces a value.

genBoth :: (TestableType a, TestableType b) => (a -> b -> c) -> (c -> a) -> (c -> b) -> GenTotal c Source Github #

A generator for a two-component value: if either component has no values then neither does the pair, and otherwise the two are drawn independently.

GenEmpty carries its proof of emptiness as a function out of the empty type, so reusing a component's proof for the pair means getting at that component first. Hence the two projections alongside the constructor.

genElements :: forall {j} {k} p (a :: k) (b :: j). (Finitary p, Ob a, Ob b) => GenTotal (p a b) Source Github #

Draw from a finitary profunctor's own enumeration, an empty hom-set being GenEmpty rather than an error: a profunctor built by the library can be empty at a pair of objects with nothing wrong. For a hand-written fixture prefer a palette of its own. testFinitary says why a generator that is the enumeration makes the round-trip law vacuous.

oneOfTotal :: [GenTotal a] -> GenTotal a Source Github #

Uniformly choose among any number of alternatives, dropping the empty ones. Plain <|> only combines two generators at 50/50, so chaining it over more than two alternatives associates pairwise and skews weight towards whichever branch ends up outermost in the resulting tree. Use this whenever there are more than two alternatives to pick fairly among.

genSuchThat :: Gen key -> (key -> Bool) -> Gen key Source Github #

Resample genKey (cheaply, within Gen) up to maxTries times until isUsable accepts the draw, before ever asking Property to commit to a choice.

A Property-level discard restarts the whole property and can trip falsify's discard-ratio limit, aborting the run. So when a later dependent draw (e.g. "a morphism out of this object") is likely to be empty for a bad choice, reject that choice here. After maxTries the last draw is returned anyway, and the caller's own discard handles it.

someElem :: Show a => [a] -> Property a Source Github #

someElemWith :: (a -> String) -> [a] -> Property a Source Github #

Generating functions

ShowP supplies the Show instance falsify needs on both parameters of a generated Fun, derived from showP; applyFunP unwraps on the way back out.

newtype ShowP a Source Github #

Supplies a Show instance derived from showP.

falsify's Show instance for Fun needs Show on both parameters, and we only ever have TestingEqShow. Rather than reinterpret a Fun a b at the wrapped type after the fact, GenFun generates at Fun (ShowP a) (ShowP b) from the start, so show applies directly and no coercion is involved. applyFunP unwraps on the way back out.

Constructors

ShowP 

Fields

Instances

Instances details
Function a => Function (ShowP a) Source Github # 
Instance details

Defined in Proarrow.Testing

Methods

function :: Gen b -> Gen (ShowP a :-> b) Github #

TestingEqShow a => Show (ShowP a) Source Github # 
Instance details

Defined in Proarrow.Testing

applyFunP :: Fun (ShowP a) (ShowP b) -> a -> b Source Github #

Apply a generated function, wrapping and unwrapping the ShowP it was generated at. Both directions are ordinary newtype constructor applications.

Assertions

check :: String -> Bool -> Property () Source Github #

Fail with the message unless the condition holds. For the assertions a worked example makes, which no generic law-checking property covers.

expect :: (Eq a, Show a) => String -> a -> a -> Property () Source Github #

Check a measured value against the expected one, showing both.

testEq :: TestingEqShow a => String -> String -> a -> String -> a -> Property () Source Github #

Check that two values are semantically equal, naming both sides so a failure says which law broke and what the two sides came out as.

eqHask :: (TestableType a, TestingEqShow b) => (a -> b) -> (a -> b) -> Property Bool Source Github #

Interactive debugging

Run a generator once in ghci and print what it produced. These trace to stdout and are for exploring a generator by hand, not for use inside a test.

sampleP :: forall {j} {k} (p :: j +-> k). (Testable j, Testable k, TestableProfunctor p) => IO (Maybe String) Source Github #