inspection-testing-0.6.2: GHC plugin to do inspection testing

Safe Haskell | None
Language | Haskell2010

Test.Inspection.Core

Description

This module implements some analyses of Core expressions necessary for Test.Inspection. Normally, users of this package can ignore this module.

Synopsis

- slice :: [(Var, CoreExpr)] -> Var -> Slice
- pprSlice :: Slice -> SDoc
- pprSliceDifference :: Slice -> Slice -> SDoc
- eqSlice :: Equivalence -> Slice -> Slice -> Bool
- eqSlice' :: Equivalence -> Slice -> Slice -> Either SDoc ()
- freeOfType :: Slice -> [Name] -> Maybe (Var, CoreExpr)
- freeOfTerm :: Slice -> [Name] -> Maybe (Var, CoreExpr)
- doesNotAllocate :: Slice -> Maybe (Var, CoreExpr)
- doesNotContainTypeClasses :: Slice -> [Name] -> Maybe (Var, CoreExpr, [TyCon])

# Documentation

slice :: [(Var, CoreExpr)] -> Var -> Slice Source #

Selects those bindings that define the given variable (with this variable first)

pprSlice :: Slice -> SDoc Source #

Pretty-print a slice

pprSliceDifference :: Slice -> Slice -> SDoc Source #

Pretty-print two slices, after removing variables occurring in both

eqSlice :: Equivalence -> Slice -> Slice -> Bool Source #

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.

eqSlice' :: Equivalence -> Slice -> Slice -> Either SDoc () Source #

Like `eqSlice` but also returns an explanation of inequality.

freeOfType :: Slice -> [Name] -> Maybe (Var, CoreExpr) Source #

Returns `True` if the given core expression mentions no type constructor anywhere that has the given name.

freeOfTerm :: Slice -> [Name] -> Maybe (Var, CoreExpr) Source #

Returns `True` if the given core expression mentions no term variable anywhere that has the given name.

doesNotAllocate :: Slice -> Maybe (Var, CoreExpr) Source #

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.

The variable is important to know the arity of the function.

doesNotContainTypeClasses :: Slice -> [Name] -> Maybe (Var, CoreExpr, [TyCon]) Source #