coverage-0.1.0.0: Exhaustivity Checking Library

Safe HaskellSafe-Inferred
LanguageHaskell2010

Coverage.Internal

Description

Module for internal representation.

Synopsis

Documentation

type Name = String Source

A type synonym for names.

type Binders lit = [Binder lit] Source

A collection of binders, as used to match products, in product binders or collections of binders in top-level declarations.

data Binder lit Source

Binders

Constructors

Var (Maybe Name) 
Lit lit 
Tagged Name (Binder lit) 
Product (Binders lit) 
Record [(Name, Binder lit)] 

Instances

Eq lit => Eq (Binder lit) 
Show lit => Show (Binder lit) 

newtype Environment Source

Environment

The language implementor should provide an environment to let the checker lookup for constructors' names (just for one type for now).

Constructors

Environment 

Fields

envInfo :: Name -> Maybe [Name]
 

data Guard Source

Guards and alternatives

Guard are abstract, and it is up to the language implementor to interpret guards abstractly. Guards can catch all cases, or represent some opaque expression which cannot be analysed.

Constructors

CatchAll 
Opaque 

Instances

type Alternative lit = (Binders lit, Maybe Guard) Source

A case alternative consists of a collection of binders which match a collection of values, and an optional guard.

data Redundant a Source

Data-type for redundant cases representation.

Constructors

DontKnow 
Redundant 
NotRedundant a 

Instances

Functor Redundant

Functor instance for Redundant (TODO: proofs).

Applicative Redundant

Applicative instance for Redundant.

Eq a => Eq (Redundant a) 
Show a => Show (Redundant a) 

data Check lit Source

Check wraps both uncovered and redundant cases.

Constructors

Check 

Instances

Eq lit => Eq (Check lit) 
Show lit => Show (Check lit) 

makeCheck :: [Binders lit] -> Redundant [Binders lit] -> Check lit Source

applyUncovered :: ([Binders lit] -> [Binders lit]) -> Check lit -> Check lit Source

wildcard :: Binder lit Source

Wildcard

genericMerge :: Ord a => (a -> Maybe b -> Maybe c -> d) -> [(a, b)] -> [(a, c)] -> [d] Source

Applies a function over two lists of tuples that may lack elements.

missingSingle :: Eq lit => Environment -> Binder lit -> Binder lit -> ([Binder lit], Maybe Bool) Source

Returns the uncovered set after one binder is applied to the set of values represented by another.

initialize :: Int -> [Binder lit] Source

Generates a list of initial binders.

missingMultiple :: Eq lit => Environment -> Binders lit -> Binders lit -> ([Binders lit], Maybe Bool) Source

missingMultiple returns the whole set of uncovered cases.

missingCases :: Eq lit => Environment -> Binders lit -> Alternative lit -> ([Binders lit], Maybe Bool) Source

missingCases applies missingMultiple to an alternative.

missingAlternative :: Eq lit => Environment -> Alternative lit -> Binders lit -> ([Binders lit], Maybe Bool) Source

missingAlternative is missingCases with guard handling.