!      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe &'456UVXf!test-fun Representation of branches of a .test-fun"Representation of one branch of a .test-fun$Representation of the branches of a . test-fun%Testable representation of functions (a -> r).{This representation supports random generation, shrinking, and printing, for property testing with QuickCheck or Hedgehog.*Higher-order functions can be represented. test-fun'Constant function, ignore the argument. test-funApply the argument (a -> b) to a value a , stored in some representation w+, and describe what to do with the result b in another function.test-fun$Apply some function to the argument a.test-funlPattern-match on the argument (in some ADT). The branches may be incomplete, in which case a default value r is used.test-fun6Pattern-match on the argument (of some integral type).test-fun2There is no value for the argument, so we're done.test-fun/Marker for truncating infinite representations.test-funiDictionary with shrinker and printer. Used as part of the representation of higher-order functions with ( ).test-fun The type of .test-funName of a constructor.test-funName of a type.test-funName of a function.test-fun%Trivial shrinker and default printer."test-fun:Evaluate a representation into the function it represents.#test-fun'Apply a binary function representation.$test-fun(Apply a ternary function representation.)test-funRemove ( nodes from evaluating a given argument a.0   !"#$%&'()*+,-./0    !"#$%&'()*+,-./ 1Safe&'UVX$D?test-funSimplify function. ?@ABCDEFGH ?@ABCDEFGHSafe&'UVX,Ptest-fun!Type of values under some context[test-fun!Prettify function representation.\test-fun'Break up lines after braces and indent.ExampleInput: v\x -> case x :: Either _ _ of { Left x1 -> case x1 of { Left x2 -> () ; Right x2 -> case x2 of {} } ; Right x1 -> () }Output: \x -> case x :: Either _ _ of { Left x1 -> case x1 of { Left x2 -> () ; Right x2 -> case x2 of {} } ; Right x1 -> () }qtest-fun'Pretty-print a function representation.vtest-funTrue if there is a Fail branch.9IKJLNMOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~9[\]ZY^_`abVWXUcSTQRdefPghijklmnopqrstuvOLNMwxyz{|}~IKJR1`1a1SafeUV/test-funPretty-printed  instance.SafeUVltest-funA "cogenerator" of a0 is a random generator of functions with domain a9. They are parameterized by a generator in the codomain r.VMore generally, we can make cogenerators to generate functions of arbitrary arities;  gen a r( is only the type of unary cogenerators. gen r -> gen (a :-> r) -- Co gen a r gen r -> gen (a :-> b :-> r) gen r -> gen (a :-> b :-> c :-> r) gen r -> gen (a :-> b :-> c :-> d :-> r) -- etc. More details#Cogenerators can be composed using  and ()E (the usual combinators for functions). The arity of a cogenerator f  g is the sum of the arities of f and g. id :: forall r. gen r -> gen r -- 0-ary cogenerator -- (1-ary) . (1-ary) = (2-ary) (.) :: (forall r. gen r -> gen (a :-> r)) -> (forall r. gen r -> gen (b :-> r)) -> (forall r. gen r -> gen (a :-> b :-> r)) -- (2-ary) . (1-ary) = (3-ary) (.) :: (forall r. gen r -> gen (a :-> b :-> r)) -> (forall r. gen r -> gen (c :-> r)) -> (forall r. gen r -> gen (a :-> b :-> c :-> r)) Note: the last type parameter r should really be universally quantified (as in the above pseudo type signatures), but instead we use more specialized types to avoid making types higher-ranked.test-funCogenerator for a type a from a cogenerator for b, given an embedding function (a -> b);, and a name for that function (used for pretty-printing).Example;The common usage is to construct cogenerators for newtypes. 1-- Given some cogenerator of Fruit cogenFruit :: c Gen Fruit r -- Wrap Fruit in a newtype newtype Apple = Apple { unApple :: Fruit } cogenApple ::  Gen Apple r cogenApple =  "unApple" cogenFruit If  cogenFruit& generates a function that looks like:  \y -> case y :: Fruit of { ... }then  cogenApple will look like this, where y is replaced with  unApple x: (\x -> case unApple x :: Fruit of { ... }test-funTCogenerator for an integral type. The name of the type is used for pretty-printing.Example cogenInteger ::  Gen  r cogenInteger =  "Integer" cogenInt ::  Gen  r cogenInt =  "Int" cogenWord ::  Gen  r cogenWord =  "Word" test-fun Variant of  with an explicit conversion to .test-fun"Extend a cogenerator of functions (a -> b)/ (i.e., a generator of higher-order functions ((a -> b) -> r)*), applying the function to a given value a2 and inspecting the result with a cogenerator of b.MThis is parameterized by a way to generate, shrink, and show values of type a) or, more generally, some representation a0 of values of type a.Example 8-- Assume Chips is some concrete type. concreteChips :: [ Chips -- Assume we have a cogenerator of Fish. cogenFish :: forall r. Gen r -> Gen (Fish   r) -- Then we can use cogenApply to construct this function -- to transform cogenerators of functions (Chips -> Fish). cogenX :: forall r. Chips -> Gen ((Chips -> Fish)   r) -> Gen ((Chips -> Fish)   r) cogenX =  concreteChips   cogenFish -- If we have some inputs... chips1, chips2, chips3 :: Chips -- ... we can construct a cogenerator of functions by iterating cogenX. cogenF :: forall r. Gen r -> Gen ((Chips -> Fish)   r) cogenF = cogenX chips1  cogenX chips2  cogenX chips3   test-fun<The trivial cogenerator which generates a constant function.test-fun%Construct a cogenerator of functions (a -> b) from a cogenerator of b , using gen (Maybe a0)0 to generate random arguments until it returns Nothing.test-funShrink and show a0. test-funReify to value a (id for simple data types). test-funValue to inspect. test-funCogenerator of b test-funShrink and show a0. test-fun-Generate representations of argument values. test-funInterpret a representation a0 into a value a (id for simple data types). test-funCogenerator of b. Safe-/=>?@AHUVXfk test-funConstraint for .test-funFThe list of cogenerators for a generic type, one for each constructor.test-fun Convert a (:*:) product into a left-nested (,) product.test-funConvert a generic  into a sum of products made of  and (,)0, where products are nested to the left (i.e., ((((), a), b), c)).test-fun)Class of types with generic cogenerators.test-funPHeterogeneous products as nested pairs. These products must be terminated by (). ,a :+ b :+ c :+ () -- the product of a, b, ctest-funImplicit, default cogenerator.test-funbCogenerator for generic types, parameterized by a list of cogenerators, one for each constructor.The list is constructed with () (pairs) and ().Example G-- Cogenerator for lists, parameterized by a cogenerator for elements.  :: forall a. (forall r.  Gen a r) -> (forall r.  Gen [a] r)  coa = e gs where -- gs :: GSumCo Gen [a] r -- unfolds to -- gs :: (gen r -> gen r) 9 -- Cogenerator for the empty list (gen r -> gen (a   [a]   r)) 6 -- Cogenerator for non-empty lists () gs = id  (coa   coa)  () test-funCogenerator for lists.Implementation noteThe cogenerator of a/ is made monomorphic only to keep the type of J at rank 1. But really, don't pay attention to the last type argument of .  :: ... =>  gen a _ ->  gen [a] _ test-funGeneric implementation of . -- Assuming MyData is a data type whose fields are all instances of CoArbitrary. instance CoArbitrary MyData where coarbitrary = coarbitraryGeneric 9 9 22 SafeUV "#$?[\ "#$?[\     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUUVWXYZ[[\]]^_`abcdefghijklmnopqrstuvwxyz{|}~'test-fun-0.1.0.0-CSMkZrvhnxD5vpKqHtYuhZTest.Fun.Internal.TypesTest.Fun.Internal.ShrinkTest.Fun.Internal.PrettyTest.Fun.Internal.OrphanTest.Fun.Internal.CoGenTest.Fun.Internal.Generic Text.Show showsPrecTest.FunBinBinEmptyBinAlt BinToShrinkFieldsNoFieldFieldBranchesFailAltPat:->ConstCoApplyApplyCase CaseIntegerAbsurdToShrinkConcreteshrinkC showsPrecC ShowsPrecConNameTypeNameFunName hardConcretecoapplyapplycase_ caseIntegeraltbinAltapplyFun applyFun2 applyFun3 applyBranches applyFieldsapplyBin applyBin'clearFun clearBranches clearFieldsclearBin clearBin' truncateFun truncateBin$fTraversableFields$fTraversableBranches$fTraversable:->$fFoldableFields$fFoldableBranches $fFoldable:->$fFunctorFields$fFunctorBranches $fFunctor:->$fEqBin$fOrdBin $fShowBin $fFunctorBin $fFoldableBin$fTraversableBin shrinkFunshrinkBranches shrinkFields shrinkBin binToShrink shrinkMaybefirstFun firstBranches firstFieldfirstBinSignPosNegEBranchEBranchEllipsis CBranchesCCtx:.VarPatternExprunExpr PrecDStringDString showsPrecFunindent prettyFunsidsstring%~%sparensunExpr_defVardefCtxbadCtxeWildeConsttConsteInteApptShowtShow_sVareVaraddVartFuntApplytCoApplytAbsurdappendIfpartialBranches bEllipsisbWildtCase tBranchestFieldsnextVar mkPatterntBinresigntBin' ellidedBin $fShow:->Co cogenEmbed cogenIntegralcogenIntegral'genBin cogenApply cogenConstcogenFun GProdCoArb gprodCoarb GSumCoArb gsumCoarb GCoArbitraryMkFieldsmkFields GenBranches genBranches_GToListgToList GNormalize gnormalize>->GSumCo_GSumCo>*> Normalize Typeable_shortTypeName_GCoGen:+ CoArbitrary coarbitrary cogenGeneric cogenList shortTypeName genBranchescoarbitraryGeneric$fCoArbitrarygenSum$fCoArbitrarygenIdentity$fCoArbitrarygenEither$fCoArbitrarygen(,)$fCoArbitrarygenMaybe$fCoArbitrarygen[]$fCoArbitrarygenOrdering$fCoArbitrarygenBool$fCoArbitrarygenWord$fCoArbitrarygenInt$fCoArbitrarygenInteger$fCoArbitrarygenVoid$fCoArbitrarygen() $fTypeable_ka $fTypeable_kf$fGNormalizeV1$fGNormalize:+:$fGNormalizeM1 $fGToListU1 $fGToListM1 $fGToList:*:$fGNormalizeM10$fGenBranchesV1$fGenBranches:+:$fGenBranchesM1 $fGCoGena $fMkFieldsU1 $fMkFieldsM1 $fMkFields:*:$fGenBranchesM10$fGSumCoArbgenV1$fGSumCoArbgen:+:$fGSumCoArbgenM1$fGCoArbitrarygena$fGProdCoArbgenU1$fGProdCoArbgenM1$fGProdCoArbgen:*:$fGSumCoArbgenM10baseGHC.ShowShowGHC.Baseid. integer-gmpGHC.Integer.TypeIntegerghc-prim GHC.TypesIntWord GHC.GenericsRep Data.EitherEither