vwbFw      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Safewxyz{|}wxyz{|}wxyz{|}5(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Safe$  !"#$%&'()*$  !"#$%&'()*$  !"#$%&'()*$  !"#$%&'()*(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None0 ~+,-./0123+,-./0123 ,-./0231+ ~+,-./0123(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None0>EExtrapolate can generalize counter-examples of any types that are >.OThe core (and only required functions) of the generalizable typeclass are the ? and B functions.8The following example shows a datatype and its instance: (data Stack a = Stack a (Stack a) | Empty instance Generalizable a => Generalizable (Stack a) where name _ = "s" expr s@(Stack x y) = constant "Stack" (Stack ->>: s) :$ expr x :$ expr y expr s@Empty = constant "Empty" (Empty -: s) instances s = this s $ instances (argTy1of1 s) To declare B and ? it may be useful to use: LeanCheck's  Test.LeanCheck.Utils.TypeBinding operators: , , , ...;Extrapolate's Test.Extrapolate.TypeBinding operators: , , , ....??Transforms a value into an manipulable expression tree. See  and .@(Common name for a variable, defaults to "x".AEList of symbols allowed to appear in side-conditions. Defaults to []. See .B+Computes a list of reified instances. See E.Usage: ins "x" (undefined :: Type)lgeneralizes an expression by making it less defined, starting with smaller changes, then bigger changes:1: change constant to variable 1.1: if a variable of the constant type exists, use it 1.2: if not, introduce new variable 2: change a variable to a new variableAThe above is the ideal, but let's start with a simpler algorithm:1: change constant to holeR0List matches of lists of expressions if possible S[0,1] `matchList` [x,y] = Just [x=0, y=1] [0,1+2] `matchList` [x,y+y] = NothingD456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde+,-./0123456798:;<=>@BA?CDEFGHIJKLMNOPQRSTUVW&>?@ABEFGCD:;<=56789HIJVWPLMNOURS45KQT6456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Noneg Derives a > instance for a given type f.Consider the following Stack datatype: (data Stack a = Stack a (Stack a) | EmptyWriting deriveGeneralizable ''Stack(will automatically derive the following > instance: [instance Generalizable a => Generalizable (Stack a) where expr s@(Stack x y) = constant "Stack" (Stack ->>: s) :$ expr x :$ expr y expr s@Empty = constant "Empty" (Empty -: s) instances s = this "s" s $ let Stack x y = Stack undefined undefined `asTypeOf` s in instances x . instances yThis function needs the TemplateHaskell extension.hSame as g4 but does not warn when instance already exists (g is preferable).i Derives a > instance for a given type f3 cascading derivation of type arguments as well.ggGiven a type name, return the number of arguments taken by that type. Examples in partially broken TH: arity ''Int === Q 0 arity ''Int->Int === Q 0 arity ''Maybe === Q 1 arity ''Either === Q 2 arity ''Int-> === Q 1ZThis works for Data's and Newtype's and it is useful when generating typeclass instances.hijghiklmnopqrstuvwgxyz{|}~ghighihijghiklmnopqrstuvwgxyz{|}~(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>NonemUse m/ to configure the number of tests performed by check. ]> check `for` 10080 $ \xs -> sort (sort xs) == sort (xs :: [Int]) +++ OK, passed 10080 tests.Don't forget the dollar ($)!nfAllows the user to customize instance information available when generalized. (For advanced users.)oUse o> to provide additional functions to appear in side-conditions. check `withBackground` [constant "isSpace" isSpace] $ \xs -> unwords (words xs) == xs *** Failed! Falsifiable (after 4 tests): " " Generalization: ' ':_ Conditional Generalization: c:_ when isSpace cpUse p1 to configure the maximum condition size allowed.q&Checks a property printing results on stdout > check $ \xs -> sort (sort xs) == sort (xs::[Int]) +++ OK, passed 360 tests. > check $ \xs ys -> xs `union` ys == ys `union` (xs::[Int]) *** Failed! Falsifiable (after 4 tests): [] [0,0] Generalization: [] (x:x:_)r(Check a property printing results on stdout and returning  on success.JThere is no option to silence this function: for silence, you should use  .mnopqrmnopqrqrmnopmnopqr(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Noneu      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde+,-./0123456798:;<=>@BA?CDEFGHIJKLMNOPQRSTUVWu(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Nonev      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde  !"#$%&'()*4>@BA?CDEghimopqrvqrmop>?@ABECD4ghivv      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~              !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGFHFIFJFKFLFMFNFOFPFQFRFSTUTVWXWYWZW[W\W]W^W_W`abacada aeafagahaiajakalamanaoapaqarasatauavawaxayaza{a|a}~(extrapolate-0.2.1-FcHrOnp6vi5IL2d083BReDTest.ExtrapolateTest.Extrapolate.CoreTest.Extrapolate.TypeBindingTest.Extrapolate.ExprsTest.Extrapolate.DeriveTest.Extrapolate.IOTest.Extrapolate.BasicTest.Extrapolate.UtilsTest.LeanCheckholds&speculate-0.2.6-BG5GU1dg7Rb7jUGgkU4NXvTest.Speculate.Expr.Core showConstantconstant:$VarConstantExpr+++ argTypes0 argTypes1 argTypes2 argTypes3 argTypes4 argTypes5 argTypes6 argTypes7 argTypes8 argTypes9 argTypes10 argTypes11 argTypes12argTys1argTys2 argTy1of1 argTy1of2 argTy2of2 argTy1of3 argTy2of3 argTy3of3 argTy1of4 argTy2of4 argTy3of4 argTy4of4 argTy1of5 argTy2of5 argTy3of5 argTy4of5 argTy5of5 argTy1of6 argTy2of6 argTy3of6 argTy4of6 argTy5of6 argTy6of6nameWithcanonicalizeWithgroundsgroundsAndBinds vassignmentsvarsisAssignmentTestfoldunfoldTestableoptions WithOptionWithpropertyoptionOptionMaxTestsExtraInstancesMaxConditionSize Generalizableexprname background instancesbgEqbgOrdthisbackgroundWith backgroundOfmaxTestsextraInstancesmaxConditionSizeresultscounterExampleGensgeneralizationsCEgeneralizationsCECgeneralizationsCountscounterExampleGenareInstancesOf matchList newMatches expressionsTconditionalGeneralizationhasEq*==*$fTestable(->)$fTestableBool$fTestableWithOption$fGeneralizableOrdering$fGeneralizable[]$fGeneralizable(,,)$fGeneralizable(,)$fGeneralizableEither$fGeneralizableMaybe$fGeneralizableChar$fGeneralizableInteger$fGeneralizableInt$fGeneralizableBool$fGeneralizable() $fShowOptionderiveGeneralizablederiveGeneralizableIfNeededderiveGeneralizableCascading$fEqBla$fOrdBla $fShowBlafor withInstanceswithBackgroundwithConditionSizecheck checkResult $fEqResult $fShowResult$fGeneralizableRatioordering nubMergeBy nubMergeOnnubMergefoldr0fromLeft fromRightelemBy MarkerTypecanonicalizeWith1unrepeatedToHole1baseData.Typeable.InternalTypeRepTest.Speculate.Expr.Canon canonicalWith canonicalizeTest.Speculate.Expr.Groundfalse trueRatio trueBindstrueinequalless lessOrEqual condEqualM condEqualequalgroundAndBinds groundBindsTest.Speculate.Expr.EquateunConditionalComparisonconditionalComparisonLTconditionalComparisonLEusefulConditionalEquationunConditionalEquationconditionalEquationusefulImplication unImplication implication unComparison comparisonLE comparisonLTusefulEquationuselessEquation isEquation unEquation phonyEquationequationTest.Speculate.Expr.InstancedefNamespreludeInstancesleEltEeqEtiersEnamesfindInfo isListableisEqOrdEisOrdEisEqEisEqOrdisOrdisEq listableWithordWitheqWithlistableeqOrdordeq instanceTypeInstance InstancesTest.Speculate.Expr.MatchhasCanonInstanceOfisCanonInstanceOf hasInstanceOf isInstanceOf unificationunify matchWithmatch2matchrenameBysub assigningassignfillBinds unfoldAppisConstantNamedisSub subexprsVsubexprs isAssignmentunrepeatedVars countVarscountVardepthElengthEconstshasVaratomicConstantsholesarity typeCorrectetyptypevalevaluatefalseEcompareComplexitycompareComplexityThen lexicompare lexicompareByeqExprCommutingshowExpr showPrecExpr showOpExpr showsOpExpr showsPrecExpr$$holeOfTyholevarTest.Speculate.Utils.TypeablemkEqnTyboolTy&leancheck-0.6.4-LgD5obmxq9nKk7KMiFXeCw Test.LeanCheck.Utils.TypeBinding-:->:->>:insgeneralizations1 resultiers$-| tinstancesOptions getBackgroundgeneralizations productWithcounterExamplescounterExampleisCounterExample countPasses expressionsTTweakestConditionisCounterExampleUnderisVarfromBackgroundOfuint4uint3uint2uint1int4int3int2int1nateithmaybstringcharbooldoublefloatintegerintund>-->>>>>>>>>>>>:->>>>>>>>>>>:> ->>>>>>>>>>>: ->>>>>>>>>>:> ->>>>>>>>>>: ->>>>>>>>>:> ->>>>>>>>>: ->>>>>>>>:> ->>>>>>>>: ->>>>>>>:> ->>>>>>>: ->>>>>>:>->>>>>>:->>>>>:>->>>>>:->>>>:>->>>>:->>>:>->>>:->>:>->:>-:>Test.LeanCheck.Tiers listsOfLengthsetsOfbagsOf noDupListsOf normalizeTdeleteTproductslistsOfproductMaybeWith product3With noDupListConssetConsbagConsTest.LeanCheck.DerivederiveListableCascadingderiveListableTest.LeanCheck.Basic addWeightofWeightcons12cons11cons10cons9cons8cons7cons6Test.LeanCheck.Core==>existsfailswitness witnesses><\\//\/+|suchThatresetdelaycons5cons4cons3cons2cons1cons0 concatMapTconcatTfilterTmapTtiersFractional listIntegraltoTiersListablelisttierstemplate-haskellLanguage.Haskell.TH.SyntaxName typeArityBlaBlederiveGeneralizableXreallyDeriveGeneralizableletintypeConstructorsArgNames lookupValN"reallyDeriveGeneralizableCascading typeConArgstypeConArgsThattypeConCascadingArgsThat normalizeTypenormalizeTypeUnitsisntInstanceOftypeConstructors isTypeSynonymtypeSynonymType|=>| mergeIFnsmergeIwhereI nubMergesghc-prim GHC.TypesTrueResultOK Falsified Exception resultsIOresultIO showResult showCEandGensshowCEshowCCEprettify