Îõ³h*"Ë!u>      !"#$%&'()*+,-./0123456789:;<=0.6Inspection Testing for Haskell(c) Joachim Breitner, 2017MITmail@joachim-breitner.de GHC specifc Safe-Inferred67ÅÆä­#inspection-testingThe result of $/, which has a more or less helpful text messageinspection-testingEquivalence of terms.inspection-testingstrict term equalityinspection-testing0ignore types and hpc ticks during the comparisoninspection-testingÈallow permuted let bindings, ignore types and hpc tick during comparisoninspection-testing2Properties of the obligation target to be checked.inspection-testingAre the two functions equal?More precisely: f is equal to g if either the definition of f is f = g, or the definition of g is g = f, or if the definitions are f = e and g = e. In general f and gÖ need to be defined in this module, so that their actual defintions can be inspected.The + indicates how strict to check for equality inspection-testingùDo none of these types appear anywhere in the definition of the function (neither locally bound nor passed as arguments) inspection-testing/Does this function perform no heap allocations. inspection-testing&Does this value contain dictionaries (except of the listed classes). inspection-testing2Does not contain this value (in terms or patterns) inspection-testing8Always satisfied, but dumps the value in non-quiet mode.inspection-testing:This data type describes an inspection testing obligation.$It is recommended to build it using ù, for backwards compatibility when new fields are added. You can also use the more mnemonic convenience functions like  or .%The obligation needs to be passed to # or $.inspection-testingëThe target of a test obligation; invariably the name of a local definition. To get the name of a function foo, write 'foo. This requires  {-# LANGUAGE TemplateHaskell #-}.inspection-testing)The property of the target to be checked.inspection-testingAn optional name for the testinspection-testing3Do we expect this property to fail? (Only used by # , not by $)inspection-testingÌThe source location where this obligation is defined. This is filled in by #.inspection-testing If this is >ä, then report errors during compilation. Otherwise, update the top-level definition with this name.inspection-testingêCreates an inspection obligation for the given function name with default values for the optional fields.inspection-testing'Declare two functions to be equal (see )inspection-testingíDeclare two functions to be equal, but ignoring type lambdas, type arguments, type casts and hpc ticks (see ). Note that -fhpcÊ can prevent some optimizations; build without for more reliable analysis.inspection-testing%Declare two functions to be equal as ()/ but also ignoring let bindings ordering (see ).inspection-testingÄDeclare two functions to be equal, but expect the test to fail (see  and Â) (This is useful for documentation purposes, or as a TODO list.)inspection-testing3Declare two functions to be equal up to types (see %), but expect the test to fail (see ).inspection-testingÂDeclare two functions to be equal up to let binding ordering (see %), but expect the test to fail (see ).inspection-testingËDeclare that in a function™@s implementation, the given type does not occur.ŠMore precisely: No locally bound variable (let-bound, lambda-bound or pattern-bound) has a type that contains the given type constructor. # $ fusedFunction  ''[]inspection-testingÛDeclare that a function™@s implementation does not contain any generic types. This is just 1 applied to the usual type constructors used in  GHC.Generics. 'inspect $ hasNoGenerics genericFunctioninspection-testingÇDeclare that a function's implementation does not include dictionaries.‘More precisely: No locally bound variable (let-bound, lambda-bound or pattern-bound) has a type that contains a type that mentions a type class. # $  specializedFunction inspection-testing A variant of &, which white-lists some type-classes. # $ fieldLens   [''Functor]!inspection-testingˆDeclare that a function's implementation does not use the given variable (either in terms or -- if it is a constructor -- in patterns). # $ foo ! 'error"inspection-testingDump the Core of the value. # $ " 'foo=This is useful when you need to inspect some values manually.#inspection-testingÌAs seen in the example above, the entry point to inspection testing is the # function, to which you pass an 0. It will report test failures at compile time.$inspection-testingThis is a variant of #æ that allows compilation to succeed in any case, and instead indicates the result as a value of type :, which allows seamless integration into test frameworks.This variant ignores the þ field of the obligation. Instead, it is expected that you use the corresponding functionality in your test framework (e.g.  :https://hackage.haskell.org/package/tasty-expected-failuretasty-expected-failure)?inspection-testing×Like newName, but even more unique (unique across different splices), and with unique nameBaseès. Precondition: the string is a valid Haskell alphanumeric identifier (could be upper- or lower-case).%#$  !"%#$  !"9 9 9 9 9 9  Safe-InferredÃåì— )inspection-testingÐSelects those bindings that define the given variable (with this variable first)*inspection-testingPretty-print a slice+inspection-testingÃPretty-print two slices, after removing variables occurring in both,inspection-testingÃThis is a heuristic, which only works if both slices have auxiliary variables in the right order. (This is mostly to work-around the buggy CSE in GHC-8.0) It also breaks if there is shadowing.@inspection-testing choices ""[]choices "abcde"Â[('a',"bcde"),('b',"acde"),('c',"abde"),('d',"abce"),('e',"abcd")]-inspection-testingReturns TrueÝ if the given core expression mentions no type constructor anywhere that has the given name.Ainspection-testing’Check if all type constructors in a slice satisfy the given predicate. Returns the binder, expression and failing constructors triple on failure..inspection-testingReturns TrueÚ if the given core expression mentions no term variable anywhere that has the given name./inspection-testingÑTrue if the given variable binding does not allocate, if called fully satisfied.’It currently does not look through function calls, which of course could allocate. It should probably at least look through local function calls.Like show, but omit the module name if it is he current moduleCinspection-testing,like prettySrcLoc, but omits the module name57123465712346Ä      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIÊ-inspection-testing-0.6-GRsY9j5Jaq6HbKW4LBQiG6Test.InspectionTest.Inspection.CoreTest.Inspection.Plugininspection-testingResultFailureSuccess Equivalence StrictEquivIgnoreTypesAndTicksEquivUnorderedLetsEquivPropertyEqualToNoTypes NoAllocation NoTypeClassesNoUseOfCoreOf ObligationtargetpropertytestName expectFailsrcLoc storeResult mkObligation=====-==~=/==/-=/~ hasNoType hasNoGenericshasNoTypeClasseshasNoTypeClassesExcept doesNotUsecoreOfinspect inspectTest $fShowResult$fDataObligation$fDataProperty$fDataEquivalenceslicepprSlicepprSliceDifferenceeqSlice freeOfType freeOfTermdoesNotAllocatedoesNotContainTypeClasses CheckResult ResSuccessResSuccessWithMessage ResFailurepluginprettyProperty checkProperty $fEnumStat$fEqStat $fOrdStat $fBoundedStat$fEqReportingMode$fEqUponFailurebase GHC.MaybeNothing newUniqueNamechoices allTyCons showTHNamemyPrettySrcLoc