w]bv      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Safe5(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Safe"vwxyz{|}~   "vwxyz{|}~ (c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None0 #$%&'()*+ !"#$%&'()*+ $%&'(*+)# #$%&'()*+(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None0 6EExtrapolate can generalize counter-examples of any types that are 6.OThe core (and only required functions) of the generalizable typeclass are the 7 and : 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 : and 7 it may be useful to use: LeanCheck's  Test.LeanCheck.Utils.TypeBinding operators: , , , ...;Extrapolate's Test.Extrapolate.TypeBinding operators: ,  ,  , ....7?Transforms a value into an manipulable expression tree. See " and .8(Common name for a variable, defaults to "x".9EList of symbols allowed to appear in side-conditions. Defaults to []. See ".:+Computes a list of reified instances. See =.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 holeK0List 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 conditionsG,-./0123456789:;<=>?@ABCDEFGHIJKLM NOP  QR STUVWXYZ[\]^_`a  !"  !"#$%&'()*+,-./0123456789:;<=>?@A#$%&'()*+BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl,-./1023456879:;<=>?@ABCDEFGHIJKLMNOPQR)6789:=>?;<2345-./01ABCQRIE@FGHOPNKL,-DJM9,-./0123456789:;<=>?@ABCDEFGHIJKLM NOP  QR STUVWXYZ[\]^_`a(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Nonec Derives a 6 instance for a given type m.Consider the following Stack datatype: (data Stack a = Stack a (Stack a) | EmptyWriting deriveGeneralizable ''Stack(will automatically derive the following 6 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.dSame as c4 but does not warn when instance already exists (c is preferable).e Derives a 6 instance for a given type m3 cascading derivation of type arguments as well.ngGiven 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.opqcderstuvwxyz{|}~ncdecdeopqcderstuvwxyz{|}~n(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>NoneiUse i/ 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 ($)!jfAllows the user to customize instance information available when generalized. (For advanced users.)kUse k> 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 clUse l1 to configure the maximum condition size allowed.m&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:_)n(Check a property printing results on stdout and returning  on success.JThere is no option to silence this function: for silence, you should use  .ijklmnijklmnmnijklijklmn(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>Noneqrstu  !"  !"#$%&'()*+,-./0123456789:;<=>?@A#$%&'()*+BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl,-./1023456879:;<=>?@ABCDEFGHIJKLMNOPQRqrstu(c) 2017 Rudy Matela$3-Clause BSD (see the file LICENSE) Rudy Matela <rudy@matela.com.br>None  !"  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl,6879:;<=cdeiklmnmnikl6789:= "!;<,cde    !"#$%&'()*()+(),()-().()/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(  (         ! "# "$ "% &' &( &) &* &+ &, &- &. &/ &0 &1 &2 &3 45 46 "7 "8 "9 ": "; "< "= "> "? "@ "A "B "C "D "E "F "G "H "I "J "K LM LN LO LP LQ LR LS LT LU "V "W "  "X "Y  Z  [  \  ]  ^  _  `  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  {  |  }  ~             (extrapolate-0.2.2-5RomTqeo5LoKLkw0LeVXqhTest.Extrapolate.UtilsTest.Extrapolate.TypeBindingTest.ExtrapolateTest.Extrapolate.ExprsTest.Extrapolate.CoreTest.Extrapolate.DeriveTest.Extrapolate.IOTest.Extrapolate.BasicTest.LeanCheckholds nubMergeBy nubMergeOnnubMerge+++foldr0fromLeft fromRightelemBy argTy1of1 argTy1of2 argTy2of2 argTy1of3 argTy2of3 argTy3of3 argTy1of4 argTy2of4 argTy3of4 argTy4of4 argTy1of5 argTy2of5 argTy3of5 argTy4of5 argTy5of5 argTy1of6 argTy2of6 argTy3of6 argTy4of6 argTy5of6 argTy6of6&speculate-0.2.8-Cw8CYQvuEi8LtOAV2sfaRPTest.Speculate.Expr.CoreVarConstant:$Expr showConstantconstantnameWithcanonicalizeWithgroundsgroundsAndBinds vassignmentsvarsisAssignmentTestfoldunfoldTestableoptions WithOptionWithpropertyoptionOptionMaxTestsExtraInstancesMaxConditionSize Generalizableexprname background instancesbgEqbgOrdthisbackgroundWith backgroundOfgeneralizationsmaxTestsextraInstancesmaxConditionSizeresultscounterExampleGensgeneralizationsCEgeneralizationsCECgeneralizationsCountscounterExampleGenareInstancesOf 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 $fShowResult$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 isListableisEqOrdEisEqOrdisEqEisEq instanceTypefindInfoeqWitheqOrdeqEeqdefNamesTest.Speculate.Expr.Ground trueRatio trueBindstrue lessOrEquallessinequal groundBindsgroundAndBindsfalseequal condEqualM condEqualTest.Speculate.Expr.EquateuselessEquationusefulImplicationusefulEquationusefulConditionalEquation unImplication unEquationunConditionalEquationunConditionalComparison unComparison phonyEquation isEquation 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-:->:->>:insgeneralizations1candidateExpressions resultiers$-| tinstancesOptions getBackground productWithcounterExamplescounterExampleisCounterExample countPasses expressionsTTisCounterExampleUnderisVarfromBackgroundOfTest.LeanCheck.CoreListablelisttiersTest.LeanCheck.TierssetsOfsetConsproductsproductMaybeWith product3With normalizeT noDupListsOf noDupListCons listsOfLengthlistsOfdeleteTbagsOfbagConsTest.LeanCheck.DerivederiveListableCascadingderiveListabletoTierstiersFractionalsuchThatresetmapT listIntegralfilterTdelaycons5cons4cons3cons2cons1cons0concatT concatMapT\\//\/><==>+|Test.LeanCheck.BasicofWeightcons9cons8cons7cons6cons12cons11cons10 addWeight witnesseswitnessfailsexistsunduint4uint3uint2uint1stringorderingnatmaybintegerint4int3int2int1intfloateithdoublecharbool>-->>>>>>>>>>>>:->>>>>>>>>>>:> ->>>>>>>>>>>: ->>>>>>>>>>:> ->>>>>>>>>>: ->>>>>>>>>:> ->>>>>>>>>: ->>>>>>>>:> ->>>>>>>>: ->>>>>>>:> ->>>>>>>: ->>>>>>:>->>>>>>:->>>>>:>->>>>>:->>>>:>->>>>:->>>:>->>>:->>:>->:>-:>template-haskellLanguage.Haskell.TH.SyntaxName typeArityBlaBlederiveGeneralizableXreallyDeriveGeneralizableletintypeConstructorsArgNames lookupValN"reallyDeriveGeneralizableCascading typeConArgstypeConArgsThattypeConCascadingArgsThat normalizeTypenormalizeTypeUnitsisntInstanceOftypeConstructors isTypeSynonymtypeSynonymType|=>| mergeIFnsmergeIwhereI nubMergesghc-prim GHC.TypesTrueResultOK Falsified Exception resultsIOresultIO showResult showCEandGensshowCEshowCCEprettify