|Maintainer||Ahn, Ki Yung <email@example.com>|
This library packages the functional peal paper 'Sparse Bitmaps for Pattern Match Coverage' submitted to ICFP 2009 by Ki Yung Ahn and Tim Sheard. You can look up the tutorial-like paper and the talk slides, which are availabel at:
Pattern matching coverage over Algebraic Data Types(ADTs) has most often been studied in the context of pattern compilation algorithms. However, it is worth considering the pattern matching coverage problem in isolation, since general solutions will be independent of the specifics of any implementation or language.
We define an intuitive and mathematically well-established bit masking semantics for pattern match coverage. We design and implement a sparse bitmap data structure, which realizes this semantics in a compact and flexible manner. This bitmap data structure supports computing coverage solutions of large programs incrementally from coverage solutions of sub-programs. It can also be used as a common data representation for pattern coverage shared between different tools (e.g., compilers, linting tools, software analysis tools) that need pattern match coverage information.
- class Expand t where
- data BIT t
- typeof :: BIT t -> t
- showB :: BIT t -> String
- showB' :: BIT t -> String
- printB :: BIT t -> IO ()
- (.&) :: BIT t -> BIT t -> BIT t
- (.&.) :: [BIT t] -> [BIT t] -> [BIT t]
- (.|) :: BIT t -> BIT t -> BIT t
- (.|.) :: [BIT t] -> [BIT t] -> [BIT t]
- neg :: BIT t -> BIT t
- reduce :: BIT t -> BIT t
- (.**) :: Expand t => BIT t -> BIT t -> BIT t
- (=:=) :: Eq t => BIT t -> BIT t -> Bool
Type product of two types is usually a product type (or pair type).
Conceptually, for example,
Int *. Bool = (Int,Bool).
*.) have at least one identity
and type product against such identities may not result in a prodcut type.
identity on (
unit *. a = a = a *. unit
Note, there can be other identities depending on how you define
a that satisfy
null(expand a) is an identity on (
unit is the most simple and basic identity among them,
which serves as a degenerate type for nullary data data constants.
type expansion rule
The definition of expand summarizes the structure of algebraic data type. Conceptually, for example,
expand unit =  -- the non-expandable degenerate type expand Bool = [unit,unit] -- True, False expand (Maybe a) = [unit, a] -- Nothing, Just a
all 0 bits (identity on (
all 1 bits (identity on (
|Bs [BIT t] t|
sequence of bits (possibley nested)
extract the type information of a given bit
typeof (O Bool) = Bool typeof (I Bool) = Int typeof (Bs [O unit,I unit] Bool) = Bool
turn bits into strings without the type information
showB (Bs [O unit,I unit] Bool) = ""
showB but takes off the outermost square bracket
showB' (Bs [O unit,I unit] Bool) = "01"
print a newline ended string produced from
showB' on the standard output