~h      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Safe    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 AEExtrapolate can generalize counter-examples of any types that are A.OThe core (and only required functions) of the generalizable typeclass are the B and E 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 E and B it may be useful to use: LeanCheck's  Test.LeanCheck.Utils.TypeBinding operators: , , , ...;Extrapolate's Test.Extrapolate.TypeBinding operators: , , , ....B?Transforms a value into an manipulable expression tree. See ) and &.C(Common name for a variable, defaults to "x".DEList of symbols allowed to appear in side-conditions. Defaults to []. See ).E+Computes a list of reified instances. See J.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 holeY0List 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] = Nothing-Canditate expressions to appear in conditionsO456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ _!`abcdefghijklmnopqr"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'$%&()     *+,-./0123458679:<;=>?@ACBDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc1ABCDEJKLFGHI=>?@9:;<NOP_`abcRWSMTUV]^\YZ45678QX[A456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^ _!`abcdefghijklmnopqr(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Nonet Derives a A instance for a given type .Consider the following Stack datatype: (data Stack a = Stack a (Stack a) | EmptyWriting deriveGeneralizable ''Stack(will automatically derive the following A 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.uSame as t4 but does not warn when instance already exists (t is preferable).v Derives a A instance for a given type 3 cascading derivation of type arguments as well.gGiven 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.tuvtuvtuvtuv(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>NonezUse z/ 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 ($)!{fAllows the user to customize instance information available when generalized. (For advanced users.)|Use |> 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 c}Use }1 to configure the maximum condition size allowed.~&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:_)(Check a property printing results on stdout and returning  on success.JThere is no option to silence this function: for silence, you should use  .z{|}~z{|}~~z{|}z{|}~None<Computes the least general generalization of two expressions lgg1 (expr [0,0]) (expr [1,1]) _,_s:: [Int] (holes: Int, Int) > lgg1 (expr [1,1::Int]) (expr [2,2,2::Int]) _:_:_ :: [Int] (holes: Int, Int, [Int]) (c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'$%&()     *+,-./0123458679:<;=>?@ACBDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#'$%&()4ACBDEFGJtuvz|}~~z|}ABCDEJ'%$&)(FG4tuv   !"#$%&'()*+,-./01201301401501601789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 00000000000000000000000000000000000000000000000000000000000000000000000000001010101010101010101010101010101 01 01 01 01 0101010101010101010101010101010101010 !0 "#$%#$&#$'()*+,-./01234567#$8#$9#$:#$;#$<#$=#$>#$?#$@#$A#$B#$C#$D#$E#$F#$G#$H#$I#$J#$K#$L#$M#$N#$O#$P#$Q#$R#$S#$T#$U#$V#$W#$X#$Y#$Z#$[#$\#$]#$^#$_#$`#$a#$b#cd#ce#cf#cg#ch#ci#cj#ck#cl#cm#cn#co#cp#qr#qs#tu#tv#tw#tx#ty#tz#t{#t|#t}#~#~#~#~ #~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~(extrapolate-0.2.4-26cYmLiQzRnAaPnj1X4FkeTest.Extrapolate.UtilsTest.Extrapolate.TypeBindingTest.ExtrapolateTest.Extrapolate.ExprsTest.Extrapolate.CoreTest.Extrapolate.DeriveTest.Extrapolate.IOTest.Extrapolate.NewTest.Extrapolate.BasicTest.LeanCheckholds nubMergeBy nubMergeOnnubMerge+++foldr0fromLeft fromRightelemBylistEqlistOrdmaybeEqmaybeOrdeitherEq eitherOrd.: argTy1of1 argTy1of2 argTy2of2 argTy1of3 argTy2of3 argTy3of3 argTy1of4 argTy2of4 argTy3of4 argTy4of4 argTy1of5 argTy2of5 argTy3of5 argTy4of5 argTy5of5 argTy1of6 argTy2of6 argTy3of6 argTy4of6 argTy5of6 argTy6of6&speculate-0.2.9-5DbhUan0lLxLgu8uTjXWElTest.Speculate.Expr.CoreVarConstant:$Expr showConstantconstantExprsnameWithcanonicalizeWithgroundsgroundsAndBinds vassignmentsvarsisAssignmentTestfoldunfoldTestable resultiers$-| tinstancesoptions WithOptionWithpropertyoptionOptionMaxTestsExtraInstancesMaxConditionSize Generalizableexprname background instancesbgEqbgOrd bgEqWith1 bgEqWith2thisbackgroundWith backgroundOfgeneralizationsmaxTestsextraInstancesmaxConditionSizeresultscounterExamplescounterExampleGensgeneralizationsCEgeneralizationsCECgeneralizationsCountscounterExampleGenareInstancesOf matchList newMatches expressionsTconditionalGeneralizationweakestConditioncandidateConditionshasEq*==**/=**<=**<*$fTestable(->)$fTestableBool$fTestableWithOption$fGeneralizableOrdering$fGeneralizable[]$fGeneralizable(,,,)$fGeneralizable(,,)$fGeneralizable(,)$fGeneralizableEither$fGeneralizableMaybe$fGeneralizableChar$fGeneralizableInteger$fGeneralizableInt$fGeneralizableBool$fGeneralizable() $fShowOptionderiveGeneralizablederiveGeneralizableIfNeededderiveGeneralizableCascading$fEqBla$fOrdBla $fShowBlafor withInstanceswithBackgroundwithConditionSizecheck checkResult $fEqResult $fShowResultgeneralizedCounterExampleslgg1lgg$fGeneralizable(,,,,,,,)$fGeneralizable(,,,,,,)$fGeneralizable(,,,,,)$fGeneralizable(,,,,)$fGeneralizableRatio argTypes0 argTypes1 argTypes2 argTypes3 argTypes4 argTypes5 argTypes6 argTypes7 argTypes8 argTypes9 argTypes10 argTypes11 argTypes12 MarkerTypecanonicalizeWith1unrepeatedToHole1baseData.Typeable.InternalTypeRepTest.Speculate.Expr.MatchBindsTest.Speculate.Expr.Instance InstancesInstanceTest.Speculate.Utils.TypeablemkEqnTyboolTyunify unificationsubrenameBy matchWithmatch2match isInstanceOfisCanonInstanceOf hasInstanceOfhasCanonInstanceOffill assigningassigntiersEpreludeInstancesordWithordnamesltE listableWithlistableleEisOrdEisOrd isListableisEqOrdEisEqOrdisEqEisEqiqE instanceTypefindInfoeqWitheqOrdeqEeqdefNamesTest.Speculate.Expr.Ground trueRatio trueBindstrue lessOrEquallessinequal groundBindsgroundAndBindsfalseequal condEqualM condEqualTest.Speculate.Expr.EquateuselessEquationusefulImplicationusefulEquationusefulConditionalEquation unImplication unEquationunConditionalEquationunConditionalComparison unComparison phonyEquation isEquation inequality implicationequationconditionalEquationconditionalComparisonLTconditionalComparisonLE comparisonLT comparisonLEvarunrepeatedVars unfoldTuple unfoldApp typeCorrecttyp subexprsVsubexprs showsPrecExpr showsOpExpr showPrecExpr showOpExprshowExpr lexicompareBy lexicomparelengthEisTupleisSubisConstantNamed isAssignmentholesholeOfTyholehasVarfalseEevaluateevaletypeqExprCommutingdepthE countVarscountVarconstscompareComplexityThencompareComplexityatomicConstantsarity$$Test.Speculate.Expr.Canon canonicalize canonicalWith&leancheck-0.6.5-HmPHGGJWVoT6L2HrxBBRtZ Test.LeanCheck.Utils.TypeBinding-:->:->>:insgeneralizations1candidateExpressionsOptions bgOrdWith1 bgOrdWith2 getBackground productWithcounterExampleisCounterExample countPasses expressionsTTisCounterExampleUnderisVarfromBackgroundOfhasOrduint4uint3uint2uint1int4int3int2int1nateithmayborderingstringcharbooldoublefloatintegerintund>-->>>>>>>>>>>>:->>>>>>>>>>>:> ->>>>>>>>>>>: ->>>>>>>>>>:> ->>>>>>>>>>: ->>>>>>>>>:> ->>>>>>>>>: ->>>>>>>>:> ->>>>>>>>: ->>>>>>>:> ->>>>>>>: ->>>>>>:>->>>>>>:->>>>>:>->>>>>:->>>>:>->>>>:->>>:>->>>:->>:>->:>-:>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